Unit Test GraphQL schemas/queries made in AWS AppSync?

六月ゝ 毕业季﹏ 提交于 2021-02-08 08:21:40

问题


I have a simple question: is there a way/program/method to create unit tests to test the API Url generated on AWS AppSync to verify the validity of created GraphQL schemas, queries, mutations, etc?


回答1:


There is an open-source AppSync Serverless plugin which has offline emulator support. You may find it useful: https://github.com/sid88in/serverless-appsync-plugin#offline-support

Another good recommendation is to have two separate AppSync APIs. One API is hosting you production traffic. The other is to test changes before they go to production. This is significantly easier if you use Cloudformation (highly recommended) to manage your infrastructure.

If you want to validate your API is working periodically (every minute or so), you could create a canary like the following:

  1. Create a Lambda function which runs on a schedule. This lambda function will make various GraphQL requests. It can emit success/failure metrics to CloudWatch.
  2. Setup a CloudWatch alarm so you can be notified if your success/failure metric is out of the ordinary.

For the canary use-case see:

https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/RunLambdaSchedule.html https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html



来源:https://stackoverflow.com/questions/54046045/unit-test-graphql-schemas-queries-made-in-aws-appsync

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!