Skip to content

Instantly share code, notes, and snippets.

View adrianhall's full-sized avatar

Adrian Hall adrianhall

View GitHub Profile
{
"version":"2017-02-28",
"operation":"GET",
"path":"/_count",
"params":{
"body": {
"query": {
"bool": {
"must": [
{ "match": { "typeName": "FAVORITE" } },
{
"version" : "2017-02-28",
"operation" : "Query",
"query" : {
"expression": "#typeName = :typeName",
"expressionNames": {
"#typeName": "typeName"
},
"expressionValues" : {
":typeName" : $util.dynamodb.toDynamoDBJson("REVIEW")
## Raise a GraphQL field error in case of a datasource invocation error
#if($ctx.error)
$util.error($ctx.error.message, $ctx.error.type)
#end
#set($result = {})
$util.qr($result.put("nextToken",$ctx.prev.result.nextToken))
$util.qr($result.put("items", $ctx.result.data.devRestaurantReviews))
$util.toJson($result)
#set($keys = [])
#foreach($id in ${ctx.prev.result.ids})
#set($key = {})
$util.qr($key.put("typeName", $util.dynamodb.toString("LOCATION")))
$util.qr($key.put("id", $util.dynamodb.toString($id)))
$util.qr($keys.add($key))
#end
{
"version": "2018-05-29",
#if($ctx.error)
$util.error($ctx.error.message, $ctx.error.type)
#end
#set($idList = [])
#foreach($item in $context.result.items)
$util.qr($idList.add($item.locationId))
#end
#set($result = {})
$util.qr($result.put("ids", $idList))
{
"version": "2018-05-29",
"operation" : "Query",
"query" : {
"expression": "typeName = :typeName",
"expressionValues" : {
":typeName" : $util.dynamodb.toDynamoDBJson("FAVORITE")
}
},
"filter": {
{
"version" : "2018-05-29",
"operation" : "Query",
"query" : {
"expression": "typeName = :typeName",
"expressionValues" : {
":typeName" : $util.dynamodb.toDynamoDBJson("LOCATION"),
}
},
"filter": {
mappingTemplates:
- type: Mutation
field: markFavorite
request: Mutation-markFavorite-request.vtl
response: common-response.vtl
kind: PIPELINE
functions:
- getLocation
- storeFavorite
functionConfigurations:
## Raise a GraphQL field error in case of a datasource invocation error
#if($ctx.error)
$util.error($ctx.error.message, $ctx.error.type)
#end
## Pass back the result from DynamoDB. **
$util.toJson($context.prev.result)
#set($id = $ctx.stash.get("locationId")+"-"+$context.stash.get("owner"))
{
"operation": "PutItem",
"key": {
"id": $util.dynamodb.toDynamoDBJson($id),
"typeName": $util.dynamodb.toDynamoDBJson("FAVORITE")
},
"attributeValues": {
"owner": $util.dynamodb.toDynamoDBJson($context.stash.get("owner")),
"locationId": $util.dynamodb.toDynamoDBJson($context.stash.get("locationId"))