0

I am using Appsync subscription for pub/sub messages. I have read some articles about subscription (like: https://docs.aws.amazon.com/appsync/latest/devguide/real-time-data.html) and all of them mentioned about specifying a GraphQL schema directive on a mutation. In my case, I have a lambda which is triggered by dynamodb streams and that lambda needs to publish the event to subscribers. How can I make this work in Appsync? I can't find any API I can use to publish event to Appsync

Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523

2 Answers2

1
  1. Create a new mutation in your schema
  2. Add a mapping template for your mutation that returns locally (i.e. has no attached datasource)
  3. Add the mutation to the required subscription
  4. Call the mutation from your lambda to notify subscribers

See here for more details: https://aws.amazon.com/premiumsupport/knowledge-center/appsync-notify-subscribers-real-time/

Ben
  • 1,759
  • 1
  • 19
  • 23
0

Do you need to include the lambda result in the event you want to publish to your clients? If so, based on what Ben provided, you will need to include the lambda result in the mutation result resolver template. And AppSync will publish the result as part of the event to your clients.

jzthinkgeek
  • 169
  • 3