AppSync Pipeline Resolver Queries returning null

0

I'm attempting to make a simple pipeline resolver query, to eventually make a multi-function resolver. No matter what I change, this returns null. My desired query involves using an index to return an array of results, but I made a new query just to remove any added variables. I've looked up every piece of documentation I can find, but there's very little resources on these JS Pipeline resolvers and only 1 query example in the official docs.

Schema Query: getUserPermissions(id: String!): UserPermissions

My resolver setup: Enter image description here

AppSync Console Query Enter image description here

  • Do you have CLI access to your DynamoDB table?

  • I don't use CLI much, but I have access to it, yes.

  • Try do a GetItem from the CLI with the same parameters and see what result you get.

KapKerm
gefragt vor 4 Monaten269 Aufrufe
1 Antwort
-1
Akzeptierte Antwort

I got a basic query with a single return to work using the example GetItem pipeline function.

I went back to my original query and kept messing with it. I eventually got it to work using this:

import { util } from '@aws-appsync/utils';
export function request(ctx) {
  return {
    operation: 'Query',
    index: 'userID-index',
    query: {
      expression: '#userID = :userID',
      expressionValues: util.dynamodb.toMapValues({ ':userID': ctx.args.userID }),
      expressionNames: { '#userID': 'userID' },
    },
  };
}

export function response(ctx) {
    return ctx.result;
}

Important notes: Ensure you've got expressionNames and your query in the Schema is setup to return ________Connection. It is not necessary to return ctx.result.items in the function or the after mapping template.

KapKerm
beantwortet vor 4 Monaten
profile picture
EXPERTE
überprüft vor 22 Tagen

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen