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.

1개 답변
-1
수락된 답변

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
답변함 4달 전
profile picture
전문가
검토됨 22일 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠