Closed jay-herrera closed 1 month ago
One solution to this could be to allow asynchronous invocation of a Lambda function, so that you can invoke the function without waiting for a response. You would still have the small lambdas, but at least you wouldn't have to worry about managing events or SNS queues
Hey @jay-herrera we just released support for async invocation of Lambda functions. Give it a try.
export function request(ctx) {
return {
operation: 'Invoke',
invocationType: 'Event',
payload: { field: 'getPost', arguments: ctx.args },
};
}
https://docs.aws.amazon.com/appsync/latest/devguide/resolver-reference-lambda-js.html
When writing a pipeline function, there should be a way to return data to the endpoint and still run some Appsync resolver function in the background. This could be very useful for things like analytics or push notifications, times when you want a user to send a request to an Appsync endpoint and get back data as soon as possible while also triggering some other mutation behind the scenes. Currently, the best way to do this would be to listen for an event on the data source that you're mutating and run a Lambda function, but that quickly becomes a mess of managing which events need to be tied to which data sources, filtering, and managing dedicated Lambda functions for small tasks. Also, it does not allow you to run side effects on Queries. I am sure there are workarounds, but first-class support would make Appsync much more enjoyable to use.