-
Notifications
You must be signed in to change notification settings - Fork 311
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
@BatchMapping support @Argument #232
Comments
Any current workarounds for this? |
A More generally, my understanding is that a Note a There is also a more advanced option to use |
I'm closing this as there isn't anything specific we can add here, but feel free to comment further. |
@rstoyanchev I think user which use spring grpahql would not care about the underlying difference between The only reason user use Further more, I think it will be great that user could custom HandlerMethodArgumentResolver. |
Re-opening to discuss further. |
@dugenkui03 I closed the issue too soon perhaps, because I don't think the proposal is feasible. I see now that you had something concrete in mind for the implementation, so let me address it. Your want to pass Arguments are one of those things. We could make them available to
@Controller
public class BookController {
public BookController(BatchLoaderRegistry registry) {
registry.forTypePair(Long.class, Author.class).registerMappedBatchLoader((authorIds, env) -> {
// return Map<Long, Author>
});
}
@SchemaMapping
public CompletableFuture<Author> author(Book book, DataLoader<Long, Author> loader) {
return loader.load(book.getAuthorId());
}
} |
@rstoyanchev Thank for your response. about cacheKey, and why
|
I think you're missing the main points. One, Two, I think the caching problem is deeper than you suspect. To work generally, the caching key would have to take into account the arguments used and the selection set. Imagine entities loaded for different parts of the response with different arguments and selection sets. There is a library called GOM that solves this problem in a general way but this is not something we are looking to do at this time. As for this not being available in GraphQL Java, you can see this issue for example graphql-java/java-dataloader#26. |
@rstoyanchev Thanks very much. I misunderstand the design philosophy of |
I think that both source and argument are necessary. It will great that
@BatchingMapping
support@Argument
.Schema like blow. 'like' means whether the visitor like this book or author, and
Book.author
bind DataLoader.query like blow:
The text was updated successfully, but these errors were encountered: