dabit3/graphql-api-cdk-serverless-postgres(新しいタブで開きます)
主要言語: TypeScript
- star 数
- 58
- watcher 数
- 3
- fork 数
- 32
- issue 数
- 3
- 最終更新
- 2021/03/08
主要言語: TypeScript
This CDK stack deploys a real-time GraphQL API built with AWS AppSync, Amazon Aurora Serverless PostgreSQL, and AWS Lambda.
To deploy this project, follow these steps.
git clone https://github.com/dabit3/graphql-api-cdk-serverless-postgres.git
cd graphql-api-cdk-serverless-postgres
npm installcd lambda-fns npm install cd ..
npm run build
cdk deploy --O cdk-exports.json
Visit the RDS dashboard and click on Query Editor. From the dropdown menu, choose the database (it should begin with appsynccdkrdsstack-aurorablogcluster).
For the Database username, choose Connect with a Secrets Manager ARN.
To sign in, you will need the ARN from the secret that was created by CDK. To get this secret, in a new window open AWS Secrets manager. Here, click on the secret that was created by CDK (it should start with AuroraBlogClusterSecret). Copy the Secret ARN to your clipboard and go back to the RDS Query Editor.
Next, use the Secret ARN as the Secrets Manager ARN and BlogDB as the name of the database. Next, press enter and click on Connect to Database.
Once signed in, create the posts table by executing the following query:
CREATE TABLE posts ( id text UNIQUE, title text, content text );
Next, visit the AppSync console and click on cdk-blog-appsync-api to view the dashboard for your API.
Next click on Queries in the left hand menu to view the query editor. From here, we can test out the API by running the following queries and mutations:
mutation createPost { createPost(post: { id: "001" title: "My first post!" content: "Hello world!" }) { id title content } } query listPosts { listPosts { id title content } } query getPostById { getPostById(postId: "001") { id title content } } mutation updatePost { updatePost(post: { id: "001" title: "My updated post!" }) { id title } } mutation deletePost { deletePost(postId: "001") }