AWS AppSync 触发 lambda

AWS AppSync trigger lambda

我目前已经使用 HotChocolate 创建了一个 .net 后端来创建 GraphQL 查询。原因是我在使用 API 网关时感觉更有控制力。

但是,我注意到 AppSync 可能是连接 DynamoDB 与 GraphQL 的首选方式。

但是,我找不到任何关于如何触发其他 lambda 的好的答案,例如更新用户。假设我想更新一个用户,当用户更新时,我想触发一个 Lambda 来通知某个列表中的所有用户该用户已更新。我的问题比那更复杂,但你明白了。

另一件事是授权。通过 AppSync 授权似乎比在 API 网关或直接在后端授权更容易。

I cannot find any good answers on how to trigger other lambdas when e.g. updating a user.

将您的 Appsync 解析器定义为 Direct Lambda Resolvers 让您有机会在 GraphQL request-response 周期中执行工作。 Appsync 使用 updateUser 变更请求上下文和参数调用您的 lambda。除了将请求的类型返回给 Appsync 之外,您的 lambda 还可以执行任意工作或触发其他工作。

I have noticed that AppSync is maybe the preferred way of connecting DynamoDB with GraphQL

AppSync 是 AWS 的托管 GraphQL 服务。

It seems easier to authorize through AppSync rather than in either API Gateway or directly in the backend

AppSync 有 multiple integrated auth options,支持一系列简单和 fine-grained 访问控制模式。