Search code examples
amazon-web-servicesgraphqlaws-appsync

AWS AppSync response sorted result?


I want to sort $ctx.result.items and reponse the sortedResult
I don't want to manually write Velocity Template Language to sort $ctx.result.items in Response Mapping. Is there any better approach to response the sortedResult in AWS AppSync ?


Solution

  • What type of sorting are you looking to do? If it's ascending/descending using a DynamoDB resolver then you can set that on the ScanIndexForward argument for this on the request template: https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-reference-dynamodb.html