-
Notifications
You must be signed in to change notification settings - Fork 320
Replace argument type with @Source
to determine source/parent
#322
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
Replace argument type with @Source
to determine source/parent
#322
Conversation
Thanks for the proposal, and I admit there is something appealing about having an The pause that I have is that the annotation does not serve any real purpose. We can work it out just fine without it, without any ambiguity that we've come across so far. In terms of developers wondering, well if someone new wants to find out how to get a hold of the parent, the answer is just declare it. I think that's as simple as it gets and you don't need to know more. From the opposite perspective as well, if we had |
To address specifically the arguments brought up:
I don't see how it could lead to a mismatch since custom arguments are before the
This is an internal implementation detail, and there is no reason to expose it. |
Thanks for your reply, I respect your final decision. I further explain the reason of this proposal. about mismatch(match incorrectly)With Conversely, if the parent/source and parameter parsed by custom MethodArgumentResolver share many characteristics, parent/source maybe easy to mismatch——That's extreme scene, maybe we can ignore. about readability of strictness model
Consider the @SchemaMapping
public X test(A a, B b, C c){
// do something and return
} Maybe developer must read source code about custom HandlerMethodArgumentResolver and the DataFetcher of parent for determining which one is parent/source(and which one will be resolved by custom HandlerMethodArgumentResolver). All the strategies about resolving parameter in |
Thanks for elaborating. For now, I'm closing this but we can always reconsider when it becomes an actual issue. |
Annotation way will be more precise.
leniency model: argument type
I think argumentType way may lead mismatch. There will be various parameter types when spring-graphql support custom
HandlerMethodArgumentResolver
.This way also require strict restriction of code:
SourceMethodArgumentResolver
must be put after otherHandlerMethodArgumentResolver
.strictness model:
@Source
Developers will easily know whether argument is source/parent by
@Source
, they don't have to look at the implementations ofHandlerMethodArgumentResolver
to determine which one supports the parameter.And there is no need to take
SourceMethodArgumentResolver
as fallback.