Created
July 22, 2019 09:25
-
-
Save koingdev/06d330f6944a9201f89f8a6b5816c1f3 to your computer and use it in GitHub Desktop.
Sample AppSync Resolver for Query Local Secondary Index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## REQUEST MAPPING | |
{ | |
"version" : "2017-02-28", | |
"operation" : "Query", | |
"index": "shopID-vendorID-index", | |
"query" : { | |
"expression": "shopID = :shopID AND vendorID = :vendorID", | |
"expressionValues" : { | |
":shopID" : $util.dynamodb.toDynamoDBJson($ctx.args.shopID), | |
":vendorID" : $util.dynamodb.toDynamoDBJson($ctx.args.vendorID) | |
} | |
} | |
} | |
## RESPONSE MAPPING | |
## Query operation always returns a set of results not just one | |
#if ($ctx.result.items.size() > 0) | |
$util.toJson($ctx.result.items[0]) | |
#else | |
null | |
#end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you import your databases like I do, make sure you get the IAM stuff correct or you won't be able to use the secondary index, you'll get a permissions error.
Details here: aws/aws-cdk#14687