-
Notifications
You must be signed in to change notification settings - Fork 320
Looking for advice on DGS DataLoader migration #1233
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
Comments
Hey @cw-juyeonyu, I'm not on the SpringQL Team, but I have answers to your questions, and I'd be interested in seeing what other ideas the Team brings.
You can either test the method with a request, or you could do some verification using reflection. If you explore the reflection approach, you could also call it using
The Spring Docs leverage @Controller, and based on that documentation it sounds like it has to be |
Thanks for the feedback. I will provide some guidance and context. Spring for GraphQL data fetchers (e.g. for @Bean
RuntimeWiringConfigurer runtimeWiringConfigurer(BatchLoaderRegistry batchLoaderRegistry) {
DataLoaderRegistry dataLoaderRegistry = DataLoaderRegistry.newRegistry().build();
batchLoaderRegistry.registerDataLoaders(dataLoaderRegistry, GraphQLContext.newContext().build());
Map<String, DataLoader<?, ?>> dataLoaderMap = dataLoaderRegistry.getDataLoadersMap();
return builder -> builder.build().getDataFetchers().values().stream()
.flatMap(map -> map.values().stream())
.forEach(fetcher -> {
if (fetcher instanceof SelfDescribingDataFetcher<?> sddf) {
Object source = sddf.getReturnType().getSource();
if (source instanceof MethodParameter parameter) {
for (Parameter param : parameter.getMethod().getParameters()) {
if (param.getType().equals(DataLoader.class)) {
// Check parameter against dataLoaderMap
}
}
}
}
});
} In short, it is not very straight forward, but should be possible. Generally, this could be a useful feature alongside the schema inspection that we could consider to make built-in or easier. The |
Thank you for your kind explanation. |
No worries, and thanks for the feedback. We may choose to make DataLoader argument checks on startup a more fist-class feature, so I will leave this issue open just a little longer. If you have further thoughts or comments based on your experience, please reach out. |
Hi Spring GraphQL Team,
We're migrating from Netflix DGS to Spring GraphQL and have questions about
DataLoader
.@SchemaMapping
Argument Resolution Validation: When using a DataLoader within a@SchemaMapping
method, how can we ensure mismatches between the DataLoader name (registered viaBatchLoaderRegistry.forName()
) and the method's parameter name intended for keys are caught at compile or startup time, rather than runtime?@DgsDataLoader
annotation, for easier management and auto-registration?Any guidance on these points for a smoother migration would be appreciated.
Thanks!
The text was updated successfully, but these errors were encountered: