-
Notifications
You must be signed in to change notification settings - Fork 3
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
No way to write initialization and finalization code with built-in resolvers.js #14
Comments
Again, I have no idea with the context of executing this resolvers.js in actual Lambda function. That makes it difficult to understand where to place the code in this resolvers.js I'd like to get the clarification the programming model of this resolvers.js in the relation with Lambda handler function. |
I see this component is requiring resolvers.js module in handler function whenever Lambda will get the request. |
No update from anyone? |
Hey @harleyguru ... sorry for the late reply here. I'm not receiving notifications from this repo for some reasons 🤔 Regarding your question, the high-level resolvers file is meant to simplify things by abstracting the lambda details (handler, event...etc). However, I definitely understand your issue. I think the solution here is to either to allow users to provide a raw handler instead of the resolver file for cases like this, or have a lower-level app sync component that does not abstract much for maximum flexibility. Do you think that would solve your issue? |
@eahefnawy Thanks for your kind response, I've been waiting for your response long time since I am using serverless components actively for our project recently and loved your good job a lot! |
If I understand this correctly we need to create a separate package for each individual lambda, and then manually stitch those lambdas into the graphql component? |
@mwawrusch That is the way I started doing it, but in the end switched to creating multiple graphql components and hooking them together by passing the appId in serverless.yml, like:
So my component named Instead of having everything as individual lambdas, we've grouped them together into services with
where our runHandler is just setting up some stuff like a logging prefix and common exception handling. |
It's common practice to write initialization process like db connection (opening db connection and reuse it in handler function) at the top of handler function and write finalization process like db closing (closing db connection before lambda container would be destroyed).
How could we do it with resolvers.js because this resolvers.js wouldn't include handler function definition?
The text was updated successfully, but these errors were encountered: