-
Notifications
You must be signed in to change notification settings - Fork 318
Support custom HandlerMethodArgumentResolver #603
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
I could look into implementing this myself if you think it is a valid idea! :) |
We have a pull request for this #325, but there hasn't been a very clear case for it yet. |
Hello @rstoyanchev, it would be extremely useful to be able to register custom method argument resolver, as an example Is there an alternative to override of AnnotatedControllerConfigurer to support this? |
Thanks for the comment, @mladenjotanovichtec. I am aware of |
Thanks for the feedback! Our use case is basically that we have leveraged the spring-mvc one in order to produce some neatly injectable data types that wrap more low level spring/http concepts such as:
These can all be rebuilt by using
So it's not really a blocker for us, it just mostly feels like a discrepancy. The fact that both spring grapqhl and spring mvc use |
hi @bystam, thanks for the additional context. I expect the logic to create such a I'm wondering about an enhancement in the This is of course not mutually exclusive with support for custom resolvers, but it could make a nice improvement, and also makes it more clear the object comes from the context and was prepared earlier. |
That could be a nice improvement indeed, if it doesn't create any confusion. I think being able to wire it by type would align well with how many similar things work in spring. I also think there is a precedence in how spring-graphql handles data loaders. Graphql-java has the loaders registered by a String name, but spring helps tucking that away and focused on what types one wishes to load. You're right that these things are indeed "execution global" and not really specific to any one data fetcher. I think my initial question comes from wanting spring graphql to be "as similar to web-mvc as possible" for the sake of onboarding people who are used to classic mvc but now get to learn graphql. |
On further thought, this could create confusion with collections, maps, container types with generics, and possibly others. Unlike data loaders where registrations are unique by type name, this is much more wide open. I'll go ahead and schedule this for 1.2. Thanks for the feedback. |
Hi. |
Spring GraphQL has a strategy interface for dynamically resolving values in schema mapping signatures called
org.springframework.graphql.data.method.HandlerMethodArgumentResolver
.The multiple built-in instances of this are set up in the
AnnotatedControllerConfigurer
which is set up with the auto-configuration. However, this doesn't scan for custom instances of it, which means one can't inject custom argument resolvers.This makes it differ from the spring-mvc counterpart with the same name:
org.springframework.web.method.support.HandlerMethodArgumentResolver
. If I read the source code correctly these are set up in here: https://github.com/spring-projects/spring-framework/blob/1e98fb607a274fc3cc49c24902d7c269f2946514/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java#L669Since they have the exact same name, I would have assumed one could also create custom ones in the Spring GraphQL like in web-mvc.
The text was updated successfully, but these errors were encountered: