-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add python/appsync-graphql-dynamodb/README.md (#124)
* feat: add python/appsync-graphql-dynamodb/README.md * feat: add python/appsync-graphql-dynamodb/README.md
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# AppSync GraphQL API Acting on DynamoDB | ||
<!--BEGIN STABILITY BANNER--> | ||
--- | ||
|
||
![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 does 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 | ||
--- | ||
<!--END STABILITY BANNER--> | ||
|
||
This an example of an AppSync GraphQL API, pointing to four resolvers doing CRUD operations with a single DynamoDB table. | ||
|
||
## 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. |