AWS Lambda to AWS AppSync

AWS Lambda → AWS AppSync GraphQL API

Create a Lambda function that triggers an AppSync GraphQL API.

In this pattern, AWS AppSync provides a a schema that allows you to manage and read todos. A Lambda function is implemented that can interact with the GraphQL API.
This function can create todos by using the codegen generated from the schema by the Amplify CLI codegen. The codegen provides the operations and the variable types, which makes it simple to interact with the AppSync GraphQL API from the Typescript function.
This pattern is useful in event driven design that trigger your AppSync function from the backend. Those changes can they easily be reflected on front-end clients in real time by using AppSync subscriptions.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/cdk-lambda-appsync

Deploy

cdk deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

1. Delete the stack: npx cdk destroy.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus".
3. You see a message confirming DELETE_COMPLETE.

Created by:

Brice Pellé

Brice Pellé

Principal Solution Architect, AppSync - AWS.