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
已提問 4 個月前檢視次數 269 次
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 天前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南