You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
queryOk {
get {
...onA {
f(arg: "a")
}
...onB {
f(arg: "b") # no problem
}
...onC {
f(arg: "b") # no problem
}
}
}
Rejected query:
# A fragment that works on any types implementing I.fragmentgenericFragmentonI {
f(arg: "b")
}
queryValidationRejected {
get {
...onA {
f(arg: "a")
}
...onB {
...genericFragment # rejected
}
...onC {
...genericFragment # rejected
}
}
}
This query is rejected by GraphQL.js's validator, complaining that f(arg: "a") and f(arg: "b") are conflicting.
This is disappointing because it discourages using interface-conditioned fragments like genericFragment above under a more derived type context (like ...on B).
The current FieldsInSetCanMerge rule only looks at the (immediate) parent type of fields when checking if they can merge.
If the parent types of {fieldA} and {fieldB} are equal or if either is not an Object Type:
...
I propose to change FieldsInSetCanMerge rule to check:
If the context types of fieldA and fieldB has non-empty intersection:
where
The context type is defined as the most derived type deduced for the current context. This is new, but it won't be difficult to implement in validators.
The intersection of two types A and B means the intersection of GetPossibleTypes(A) and GetPossibleTypes(B) as in the Fragment Spread Is Possible section of the spec.
The text was updated successfully, but these errors were encountered:
One thing to consider here is if we lift this restriction then adding implements I to type A would be a breaking change, since a previously valid query:
(This idea was inspired by apollographql/federation#2952 .)
Motivating example
Schema:
Accepted query:
Rejected query:
This query is rejected by GraphQL.js's validator, complaining that
f(arg: "a")
andf(arg: "b")
are conflicting.This is disappointing because it discourages using interface-conditioned fragments like
genericFragment
above under a more derived type context (like...on B
).Potential improvement in FieldsInSetCanMerge(set)
The current
FieldsInSetCanMerge
rule only looks at the (immediate) parent type of fields when checking if they can merge.I propose to change
FieldsInSetCanMerge
rule to check:where
The text was updated successfully, but these errors were encountered: