You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AWS AppSync/GraphQL subscriptions coupled with AWS Amplify sound amazing, since out of the box you can subscribe all your clients to high-level domain events specified in your schema.
Though it seems like a natural extension that there should be a way to broadcast all those events to a service like lambda or SNS to react internally to those events. Maybe you want to log the events, re-index or aggregate updated data, or send an email or push notification to a user. Just like DynamoDB Streams allows you to trigger a lambda upon to updates on a table. Is anyone aware of a good way to achieve this?
There appears to be no AppSync trigger source for lambda, but it seems like there might be a couple of ways to do this otherwise:
Create a long-running process/service on ECS/Fargate that subscribes to every mutation it wants to broadcast to SNS/Lambda. Though you would have to manage and scale that process yourself 😬
Use DynamoDB Streams as a lambda trigger. However, a DynamoDB table change event is lower-level than a GraphQL mutation event, and this assumes your only data source is DynamoDB, whereas AppSync/GraphQL can plug into many other data sources.
Create lambda resolvers for every mutation that also broadcast the event to SNS/Lambda. For simply broadcasting SNS events, perhaps theres a clever way to use pipeline resolvers to attach a reusable resolver to every mutation...
I'm not sure how the Amplify framework powers their @searchable transformer, whether its the 2nd or 3rd method, or something else altogether, but it seems like that's in the same ballpark (re-indexing the data in Elasticsearch in response to an update). I do remember hearing you can write your own transformers ... perhaps one could write their own transformer @broadcasted that also broadcasts all mutation events to SNS 🤔
I'm surprised I haven't seen much if any discussion surrounding this topic. If anyone has some ideas or if I'm thinking about this the wrong way let me know!
The text was updated successfully, but these errors were encountered:
scherroman
changed the title
How can I trigger a Lambda function or SNS event in response to an AppSync GraphQL Mutation?
Can I trigger a Lambda function or SNS event in response to an AppSync GraphQL Mutation?
Jul 1, 2019
Which Category is your question related to?
Usage Question
What AWS Services are you utilizing?
Amplify, AppSync, Lambda, SNS, DynamoDB
Provide additional details e.g. code snippets
AWS AppSync/GraphQL subscriptions coupled with AWS Amplify sound amazing, since out of the box you can subscribe all your clients to high-level domain events specified in your schema.
Though it seems like a natural extension that there should be a way to broadcast all those events to a service like lambda or SNS to react internally to those events. Maybe you want to log the events, re-index or aggregate updated data, or send an email or push notification to a user. Just like DynamoDB Streams allows you to trigger a lambda upon to updates on a table. Is anyone aware of a good way to achieve this?
There appears to be no AppSync trigger source for lambda, but it seems like there might be a couple of ways to do this otherwise:
Create a long-running process/service on ECS/Fargate that subscribes to every mutation it wants to broadcast to SNS/Lambda. Though you would have to manage and scale that process yourself 😬
Use DynamoDB Streams as a lambda trigger. However, a DynamoDB table change event is lower-level than a GraphQL mutation event, and this assumes your only data source is DynamoDB, whereas AppSync/GraphQL can plug into many other data sources.
Create lambda resolvers for every mutation that also broadcast the event to SNS/Lambda. For simply broadcasting SNS events, perhaps theres a clever way to use pipeline resolvers to attach a reusable resolver to every mutation...
I'm not sure how the Amplify framework powers their @searchable transformer, whether its the 2nd or 3rd method, or something else altogether, but it seems like that's in the same ballpark (re-indexing the data in Elasticsearch in response to an update). I do remember hearing you can write your own transformers ... perhaps one could write their own transformer @broadcasted that also broadcasts all mutation events to SNS 🤔
I'm surprised I haven't seen much if any discussion surrounding this topic. If anyone has some ideas or if I'm thinking about this the wrong way let me know!
The text was updated successfully, but these errors were encountered: