在AWS AppSync中进行单元测试GraphQL模式/查询吗? [英] Unit Test GraphQL schemas/queries made in AWS AppSync?

查看:67
本文介绍了在AWS AppSync中进行单元测试GraphQL模式/查询吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的问题:是否有一种方法/程序/方法来创建单元测试,以测试在AWS AppSync上生成的API网址,以验证所创建的GraphQL模式,查询,变异等的有效性?

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?

推荐答案

有一个开源AppSync Serverless插件,具有离线模拟器支持.您可能会发现它很有用: https://github.com/sid88in/serverless-appsync-plugin#offline-support

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

另一个好的建议是拥有两个单独的AppSync API.一种API托管您的生产流量.另一种是在变更投入生产之前对其进行测试.如果您使用 Cloudformation (强烈建议)来管理基础架构,则这将非常容易.

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.

如果要验证API是否定期(每分钟左右)运行,可以创建如下所示的canary:

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

  1. 创建按计划运行的Lambda函数.此lambda函数将发出各种GraphQL请求.它可以向CloudWatch发出成功/失败指标.
  2. 设置CloudWatch警报,以便在成功/失败指标异常时通知您.

有关金丝雀的用例,请参见:

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

这篇关于在AWS AppSync中进行单元测试GraphQL模式/查询吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆