AWS AppSync 中的单元测试 GraphQL schemas/queries?
Unit Test GraphQL schemas/queries made in AWS AppSync?
我有一个简单的问题:是否有 way/program/method 创建单元测试来测试在 AWS AppSync 上生成的 API Url 以验证创建的 GraphQL 模式、查询的有效性、突变等?
有一个开源 AppSync Serverless 插件,它支持离线模拟器。您可能会发现它很有用:https://github.com/sid88in/serverless-appsync-plugin#offline-support
另一个好的建议是使用两个单独的 AppSync API。一个 API 正在托管您的生产流量。另一种是在将更改投入生产之前对其进行测试。如果您使用 Cloudformation(强烈推荐)来管理您的基础架构,这会容易得多。
如果您想验证您的 API 是否定期(每分钟左右)工作,您可以创建如下所示的金丝雀:
- 创建一个按计划运行的 Lambda 函数。这个 lambda 函数将发出各种 GraphQL 请求。它可以向 CloudWatch 发出 success/failure 指标。
- 设置 CloudWatch 警报,以便在您的 success/failure 指标异常时收到通知。
对于金丝雀用例,请参阅:
https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/RunLambdaSchedule.html
https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html
还有 amplify amplify-appsync-simulator package that is supposed to help with testing appsync, but there is no documentation on how you should use it. It is used by serverless-appsync-simulator Michael 写了 Amplify 本身。
我有一个简单的问题:是否有 way/program/method 创建单元测试来测试在 AWS AppSync 上生成的 API Url 以验证创建的 GraphQL 模式、查询的有效性、突变等?
有一个开源 AppSync Serverless 插件,它支持离线模拟器。您可能会发现它很有用:https://github.com/sid88in/serverless-appsync-plugin#offline-support
另一个好的建议是使用两个单独的 AppSync API。一个 API 正在托管您的生产流量。另一种是在将更改投入生产之前对其进行测试。如果您使用 Cloudformation(强烈推荐)来管理您的基础架构,这会容易得多。
如果您想验证您的 API 是否定期(每分钟左右)工作,您可以创建如下所示的金丝雀:
- 创建一个按计划运行的 Lambda 函数。这个 lambda 函数将发出各种 GraphQL 请求。它可以向 CloudWatch 发出 success/failure 指标。
- 设置 CloudWatch 警报,以便在您的 success/failure 指标异常时收到通知。
对于金丝雀用例,请参阅:
https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/RunLambdaSchedule.html https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html
还有 amplify amplify-appsync-simulator package that is supposed to help with testing appsync, but there is no documentation on how you should use it. It is used by serverless-appsync-simulator Michael 写了 Amplify 本身。