This repository contains a way to interact with the data residing in your MongoDB cluster with a managed GraphQL API backed by AWS AppSync
This project leverages the Serverless Application Model (SAM) to deploy a serverless application in your AWS account. It utilizes AWS Lambda as a serverless function that contains the logic to interact with your MongoDB cluster. In addition to the lambda function, it will setup an AppSync API in the AWS Console that you will use on top of the lambda function to query your data in MongoDB.
The deployed lambda function will offer you the following operations to interact with your data residing in MongoDB:
- findOne
- find
- insertOne
- insertMany
- updateOne
- updateMany
- deleteOne
- deleteMany
- aggregate
- In your AWS account, go the Lambda console. Click on the Applications section present on the right
- Click on Create Application present on the top right.
- Select Serverless application
- Search for MongoDB-AppSync-App in the search bar and check the box that says Show apps that create custom IAM roles or resource policies. Select the application highlighted.
- Enter the name of the application, your MongoDB Atlas Cluster Connection Endpoint then check the acknowledgement box and click on Deploy.
After you click on Deploy, AWS will initiate a cloudformation stack which will create a lambda function in your AWS account.
- Check the Outputs section in your cloudformation stack, you will find the following artifacts:
There are 2 ways in which you can test the deployed AppSync API with Lambda resolver as a data source:
The API request and response payloads maintain the structure previously used by DataAPI If you plan to test your queries from the AppSync console then refer the following sample queries here.