Created
April 13, 2018 22:27
-
-
Save adrianhall/a5c6370cd16f1fe2a06c50cb008268d5 to your computer and use it in GitHub Desktop.
The resolver resources in CloudFormation format.
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
AppSyncAllNotesQueryResolver: | |
Type: "AWS::AppSync::Resolver" | |
DependsOn: AppSyncSchema | |
Properties: | |
ApiId: !GetAtt AppSyncApi.ApiId | |
TypeName: Query | |
FieldName: allNotes | |
DataSourceName: !GetAtt AppSyncNotesTableDataSource.Name | |
RequestMappingTemplate: | | |
{ | |
"version": "2017-02-28", | |
"operation": "Query", | |
"query": { | |
"expression": "UserId = :id", | |
"expressionValues": { | |
":id": $util.dynamodb.toDynamoDBJson($ctx.identity.sub) | |
} | |
} | |
}, | |
"limit": $util.defaultIfNull(${ctx.args.limit}, 20), | |
"nextToken": $util.toJson(${ctx.args.nextToken}) | |
ResponseMappingTemplate: | | |
{ | |
"notes": $util.toJson($ctx.result.items), | |
"nextToken": $util.toJson(${ctx.args.nextToken}) | |
} | |
AppSyncGetNoteQueryResolver: | |
Type: "AWS::AppSync::Resolver" | |
DependsOn: AppSyncSchema | |
Properties: | |
ApiId: !GetAtt AppSyncApi.ApiId | |
TypeName: Query | |
FieldName: getNote | |
DataSourceName: !GetAtt AppSyncNotesTableDataSource.Name | |
RequestMappingTemplate: | | |
{ | |
"version": "2012-02-28", | |
"operation": "GetItem", | |
"key": { | |
"NoteId": $util.dynamodb.toDynamoDBJson($ctx.args.NoteId), | |
"UserId": $util.dynamodb.toDynamoDBJson($ctx.identity.sub) | |
} | |
} | |
ResponseMappingTemplate: "$util.toJson($ctx.result)" | |
AppSyncSaveNoteMutationResolver: | |
Type: "AWS::AppSync::Resolver" | |
DependsOn: AppSyncSchema | |
Properties: | |
ApiId: !GetAtt AppSyncApi.ApiId | |
TypeName: Mutation | |
FieldName: saveNote | |
DataSourceName: !GetAtt AppSyncNotesTableDataSource.Name | |
RequestMappingTemplate: | | |
{ | |
"version": "2012-02-28", | |
"operation": "PutItem", | |
"key": { | |
"NoteId": $util.dynamodb.toDynamoDBJson($ctx.args.NoteId), | |
"UserId": $util.dynamodb.toDynamoDBJson($ctx.identity.sub) | |
}, | |
"attributeValues": { | |
"title": $util.dynamodb.toDynamoDBJson($ctx.args.title), | |
"content": $util.dynamodb.toDynamoDBJson($ctx.args.content) | |
} | |
} | |
ResponseMappingTemplate: "$util.toJson($ctx.result)" | |
AppSyncDeleteNoteMutationResolver: | |
Type: "AWS::AppSync::Resolver" | |
DependsOn: AppSyncSchema | |
Properties: | |
ApiId: !GetAtt AppSyncApi.ApiId | |
TypeName: Mutation | |
FieldName: deleteNote | |
DataSourceName: !GetAtt AppSyncNotesTableDataSource.Name | |
RequestMappingTemplate: | | |
{ | |
"version": "2012-02-28", | |
"operation": "DeleteItem", | |
"key": { | |
"NoteId": $util.dynamodb.toDynamoDBJson($ctx.args.NoteId), | |
"UserId": $util.dynamodb.toDynamoDBJson($ctx.identity.sub) | |
} | |
} | |
ResponseMappingTemplate: "$util.toJson($ctx.result)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment