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

Feature: Add an API for giving workers more helpers #113

Open
hcharley opened this issue May 5, 2020 · 4 comments
Open

Feature: Add an API for giving workers more helpers #113

hcharley opened this issue May 5, 2020 · 4 comments

Comments

@hcharley
Copy link

hcharley commented May 5, 2020

Usecase

Give users of graphile-worker the ability to pass in custom helpers. This could include custom database connection objects, metadata, application-specific helpers, etc...

For example:

My specific usecase is to pass a Slonik database connection object.

Implementation

// TODO: add an API for giving workers more helpers

It looks like if this TODO was done, this usecase could be satisified.

I'm not sure what the ultimate implementation would look like. Would there be a specific file like helpers.ts that would be loaded and named exports would automatically be included?

Pitfalls/Things to watch out for

  • Naming conflicts with existing helpers -- Is it okay to override?
@benjie
Copy link
Member

benjie commented May 6, 2020

Is there a reason to not simply const helpers = require('../helpers') inside the worker?

@hcharley
Copy link
Author

hcharley commented May 6, 2020

No, that seems like a good solution. I can try that out. Thanks!

@benjie
Copy link
Member

benjie commented May 11, 2020

[semi-automated message] Thanks for your question; hopefully we're well on the way to helping you solve your issue. This doesn't currently seem to be a bug in the library so I'm going to close the issue, but please feel free to keep requesting help below and if it does turn out to be a bug we can definitely re-open it 👍

You can also ask for help in the #help-and-support channel in our Discord chat.

@benjie benjie closed this as completed May 11, 2020
@StepanMynarik
Copy link

@benjie
Just encountered this.

The TODO is still there and I believe that in certain situations this would allow for much more pleasurable DX.

For example in our case we have set up nodemailer instance for fastify route plugin consumption. All setup and "service" init is defined in server.ts. All works beautifully.
But then I integrated Graphile Worker and now I need the nodemailer instance in my tasks to send e-mails. Would be elegant as heck with helpers object augmentation. Without it, I have to refactor.

Not the end of the world, don't get me wrong, Graphile Worker is an amazing alternative to pg-boss!
But this little thing would definitely make it even better.

@benjie benjie reopened this Mar 26, 2024
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

3 participants