Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appsync should have a built in way to produce side effects in a pipeline function #356

Open
jay-herrera opened this issue Mar 22, 2024 · 2 comments

Comments

@jay-herrera
Copy link

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.

@jay-herrera
Copy link
Author

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

@onlybakam
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants