Description
To customize controller argument binding you have to use HandlerMethodArgumentResolver
which can bind any number GraphQl argument to single method parameter, the interface is quite flexible but requires more work. Also, no more @Argument
on the handler parameters, which makes things less obvious.
As a motivation, GraphQL Java recently added support for @oneof
directive for input types, to get the most out of it, you will need to customize the handling for arguments based on a directive(rolling out the usage of Converter
).
I really like the signature of the bind method on GraphQlArgumentBinder
:
public Object bind(DataFetchingEnvironment environment, @Nullable String name, ResolvableType targetType)
throws BindException {...}
(Can we get rid of the @Nullable
? matching the Argument in GraphQlArgumentBinder
)
One solution would be to introduce a new abstraction and do Spring's standard way of registering beans implementing said abstraction and the framework would auto wire them in the right place.
Another solution is to change GraphQlArgumentBinder
and make it more friendly to user extension. e.g. make most methods protected
, add an extension point for implementers, and register it as a bean so users can replace it.