# AppSync GraphQL API Acting on DynamoDB --- ![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge) > **This is an experimental example. It may not build out of the box** > > This examples is build on Construct Libraries marked "Experimental" and may not be updated for latest breaking changes. > > If build is unsuccessful, please create an [issue](https://github.com/aws-samples/aws-cdk-examples/issues/new) so that we may debug the problem --- This an example of an AppSync GraphQL API, pointing to four resolvers doing CRUD operations with a single DynamoDB table. ![Detailed diagram](diagram.png) ## Build To build this app, you need to be in this example's root folder. Then run the following: ```bash $ python3 -m venv .env $ source .env/bin/activate $ pip install -r requirements.txt ``` This will install the necessary CDK, then this example's dependencies, and then build your Python files and your CloudFormation template. Install the latest version of the AWS CDK CLI: ```shell $ npm i -g aws-cdk ``` ## Deploy Run `cdk deploy`. This will deploy / redeploy your Stack to your AWS Account. After the deployment you will see the API's URL, which represents the url you can then use. ## Synthesize Cloudformation Template To see the Cloudformation template generated by the CDK, run `cdk synth`, then check the output file in the "cdk.out" directory. ## The Component Structure This Stack contains: - a __GraphQL API__ with an API Key (Use with caution, each key is only valid for 7 days.) - a __GraphQL Schema__ with Queries to get one and all items and two mutations to save and delete an item - a __DynamoDB table__ `items` that stores the data with a Pay Per Request Billing Mode - an __IAM Role__ that allows AppSync to invoke your DynamoDB table. - an __AppSync DataSource__, connecting your API to the DynamoDB table with the previously specified role. - a __AppSync Resolver__ for a Query `getOne` to get one item from the DynamoDB table. - a __AppSync Resolver__ for a Query `all` to get all items from the DynamoDB table. - a __AppSync Resolver__ for a Mutation `save` to put an item into the DynamoDB table (the id is autogenerated, you need only name). - a __AppSync Resolver__ for a Mutation `delete` to delete one item from the DynamoDB table.