Reputation: 307
Example Problem:
A user can post their own articles on our website. However, each user can only post 5 articles and when they post their 5th article, we want to send them an email.
Using revolvers only, is it possible to return the mutation response on time and then lazily/async invoke a lambda function that sends an email to the user?
Upvotes: 1
Views: 1306
Reputation: 5775
Yes, that should be very possible. It depends a bit on what kind of resolver you want to use. If you were using a Lambda data source:
If you were using a DynamoDB data source:
In any case, you might find pipeline resolvers to be useful. It allows you to set up a linear, synchronous chain of resolvers to solve some more complex problems. You could have an initial Lambda function/DDB lookup to get the number of posts (and potentially fail if someone is at their limit), then a second resolver after that to do your normal action, then potentially even a third that could send the email that someone has hit the limit.
Upvotes: 4