spring-projects / spring-projects/spring-graphql
Allow for more customization in GraphQlArgumentBinder
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 336
- PR merge metrics
- No merged PRs in 30d
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 @Argumenton 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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with GraphQlArgumentBinder and its bind method, then compare the existing HandlerMethodArgumentResolver approach described in the issue. Review how Converter and @Argument are currently involved in argument binding. Done means agreeing on and implementing a clear extension or registration point for customized GraphQL argument handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, java
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100