• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

dabit3/graphql-api-cdk-serverless-postgres

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

dabit3/graphql-api-cdk-serverless-postgres

开源软件地址(OpenSource Url):

https://github.com/dabit3/graphql-api-cdk-serverless-postgres

开源编程语言(OpenSource Language):

TypeScript 49.6%

开源软件介绍(OpenSource Introduction):

CDK API with GraphQL and Aurora Serverless PostgreSQL

This CDK stack deploys a real-time GraphQL API built with AWS AppSync, Amazon Aurora Serverless PostgreSQL, and AWS Lambda.

CDK API with GraphQL and Aurora Serverless PostgreSQL

Getting started

To deploy this project, follow these steps.

  1. Clone the project
git clone https://github.com/dabit3/graphql-api-cdk-serverless-postgres.git
  1. Change into the new directory and install dependencies
cd graphql-api-cdk-serverless-postgres

npm install
  1. Change into the lambda-fns directory and install the dependencies for the Lambda function package:
cd lambda-fns
npm install
cd ..
  1. Run the build
npm run build
  1. Deploy the stack
cdk deploy --O cdk-exports.json
  1. Create the posts table

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
);
  1. Testing the API

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")
}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap