-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Assert matching response shapes in fields_will_merge #4347
base: master
Are you sure you want to change the base?
Conversation
else | ||
true | ||
end | ||
elsif type2.list? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparing this with the graphql-js implementation... Shouldn't this return true
?
if (isListType(type2)) {
return true;
}
end | ||
elsif type2.non_null? | ||
true | ||
elsif !type1.kind.fields? && !type2.kind.fields? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again comparing this with graphql-js
, I believe this should be an OR...
if (isLeafType(type1) || isLeafType(type2)) {
return type1 !== type2;
}
So !type1.kind.fields?
should be equivalent to isLeafType(type1)
, at which time the compound condition shouldn't need to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revisiting this again today, I've noticed another issue with the fields?
check in general... Right now, Union does not belong to fields
which makes the fields?
check a rather ambiguous slice across both Leaf and Composite distinctions. Technically Union should probably belong to fields?
, although I imagine that change could have a huge blast radius across community implementations.
My suggestion then would be to introduce a proper leaf?
distinction (ie: scalar? || enum?
), and then refactor the core library to revolve around formal leaf?
and composite?
distinctions, and allow fields?
to fade away into the sunset (while remaining present to support existing community usage).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, yes... this is a breaking change that will start rejecting queries that used to be accepted. Probably the smoothest path to reaching spec would be to make this an opt-in setting on |
Oops, it seems like one part of
FieldsWillMerge
was missing. Adding it now might break some queries that used to work, so I may have to ensure there's a way to opt out of this change.From the spec:
https://spec.graphql.org/draft/#SameResponseShape()
In GraphQL-JS:
https://github.com/graphql/graphql-js/blob/f201681bf806a2c46c4ee8b2533287421327a302/src/validation/rules/OverlappingFieldsCanBeMergedRule.ts#L691-L718
https://github.com/graphql/graphql-js/blob/a24a9f35b876bdd0d5050eca34d3020bd0db9a29/src/validation/__tests__/OverlappingFieldsCanBeMergedRule-test.ts#L738-L767
TODO: