Is it possible to execute more than one operation in appsync javascript resolver?

125 Views Asked by At

I want to send a query with filterexpression and limit in javascript resolver to DynamoDB . DynamoDB returns the matching values up to the limit, and a key in LastEvaluatedKey to apply in a subsequent operation to continue the operation. It is possible to get zero matched items at first operation. How can I implement in javascript resolver to send again a subsequent operation to get all matched items to the limit? In another word, how can I paginate in javascript resolver? Not pagination at Client. Or I have to implement in lamdbda function to get all matched items to the limit?

1

There are 1 best solutions below

0
On BEST ANSWER

You are forced to implement client side logic to meet this use-case. The alternative is to set your limit considerably higher than you need, and discard the items you don't need when returned.

The issue isn't Appsync, but how DynamoDB implements filtering, which I assume is what you are doing. The limit is applied before the FilterExpression, meaning you can get <=Limit number of items. To apply your custom logic for pagination you will need to use a Lambda Resolver.