-
Notifications
You must be signed in to change notification settings - Fork 7
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
why do loaders need to be in context? #240
Comments
can you give examples of your idea? |
We need loaders in GraphQL context because they use dataloader under the hood to provide cache and batch for our database queries you should not share this cache between requests what do you recommend? |
Suggestion 1, https://github.com/entria/graphql-mongo-helpers/blob/master/src/createLoader.ts#L80 Suggestion 2, createLoader({
name: 'UserLoader',
getLoader: (ctx) => ctx.userLoader; // here it is optional for the developer to choose where to get it.
}) on second thought, maybe the first suggestion is not so valid, because it creates an instance globally and not for request |
i didn't understand the need of context loaders, maybe how it's currently is the best way |
I do like your second suggestion, feel free to implement it add tests to avoid regressions, and keep the old default behavior |
this is not such an obvious thing when trying to use the lib, and it becomes difficult to use it
suggestion:
The text was updated successfully, but these errors were encountered: