## Below example shows how to look up an item with a Primary Key of "id" from GraphQL arguments ## The helper $util.dynamodb.toDynamoDBJson automatically converts to a DynamoDB formatted request ## There is a "context" object with arguments, identity, headers, and parent field information you can access. ## It also has a shorthand notation avaialable: ## - $context or $ctx is the root object ## - $ctx.arguments or $ctx.args contains arguments ## - $ctx.identity has caller information, such as $ctx.identity.username ## - $ctx.request.headers contains headers, such as $context.request.headers.xyz ## - $ctx.source is a map of the parent field, for instance $ctx.source.xyz ## Read more: https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-reference.html #set( $queryExpressionNames = { "#Stream_ID": "Stream_ID" }) #set($queryExpressionValues = {":Stream_ID": $util.dynamodb.toDynamoDB($ctx.args.Stream_ID)}) #if($util.isNullOrEmpty($context.arguments.After)) #set($queryExpression = "#Stream_ID = :Stream_ID") #else #set($queryExpression = "#Stream_ID = :Stream_ID and #Start_DateTime > :Start_DateTime") $util.qr($queryExpressionNames.put("#Start_DateTime", "Start_DateTime")) $util.qr($queryExpressionValues.put(":Start_DateTime", $util.dynamodb.toDynamoDB($ctx.args.After))) #end { "version": "2017-02-28", "operation": "Query", "query": { "expression": "${queryExpression}", "expressionNames": $utils.toJson($queryExpressionNames), "expressionValues": $utils.toJson($queryExpressionValues), }, "filter" : { "expression" : "attribute_exists(#f)", "expressionNames" : { "#f" : "Finished" } }, "limit": $util.defaultIfNull($ctx.args.limit, 20), "nextToken": $util.toJson($util.defaultIfNullOrEmpty($ctx.args.nextToken, null)), "scanIndexForward": false, "select": "ALL_ATTRIBUTES", }