-
Notifications
You must be signed in to change notification settings - Fork 113
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
Request-scoped DataLoader #59
Comments
Would it make sense to always add the |
Always adding Or are you thinking about supporting |
@vojtechhabarta 's diff could help the GraphQLServlet to have per-request instrumentation. Ideas:
public class GraphQLContext {
public class ContextA extends GraphQLContext{
}
|
I would like to solve this problem somehow. I have 2 use cases:
Any idea, solution, hack...? |
@vojtechhabarta, @freedomljc I LOVE your ideas to implement "instrumentation per request" . Our project is using @deprecated BatchedExecutionStrategy we want to change to use DataLoader but stuck at configure DataLoader per request. Have you guys tried to implement it? |
I haven't implemented it. I thought somebody who understands better than me how GraphQL in Java works should do it 😏 |
Will this PR help? #83. |
@ashu-walmart, hopefully your PR is reviewed and merged soon. |
I make a pull request graphql-java/graphql-java#1171 for this with |
@ashu-walmart et al. Anything still needed for this in this project? PR #83 has been merged. So like to know if there's still some functionality missing we need to implement. Also, if you're able to write a small readme explaining this feature for future reference would be much appreciated. |
@oliemansm, This works for me now and am using the feature in my project. I will write a readme describing the feature. Thanks! |
I am trying to use DataLoaders. If I understand it correctly:
DataLoaderRegistry
for each user request (to prevent mixing caches for different users)DataLoaderRegistry
can be stored in custom context class which is instantiated inGraphQLServlet.createContext
(in override or usingGraphQLContextBuilder
)DataLoaderRegistry
from this contextDataLoaderDispatcherInstrumentation
must be used so thatdispatch
methods are calledbut here is the problem:
DataLoaderDispatcherInstrumentation
hasDataLoaderRegistry
and it is not request-scoped.I haven't find a way to have request-scoped
DataLoaderRegistry
so I would like to improve the servlet to allow this use case. Or am I missing something?Methods
createContext
andgetInstrumentation
need to somehow share newDataLoaderRegistry
(per-request) instance. One solution would be to add methodsgetInstrumentation
withGraphQLContext
parameter, delegate these methods to their parameter-less versions and call this new method fromnewGraphQL
method.If you think this would be useful I can create PR (I already tried it). Or is there a better way?
The text was updated successfully, but these errors were encountered: