-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow fields to diverge more? #820
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
Comments
{
pets {
... on Cat {
value: catValue
}
... on Dog {
value: dogValue
}
}
} For the above query, this has different return types in the same response shape. Both of these responses would need to be valid: {
"data": {
"pets": {
"value": 123
}
}
} {
"data": {
"pets": {
"value": 123.456
}
}
} I believe the logic here is that the response shape needs to be unambiguous. If you have a generated parser for this query, what type should the parser use for To be fair, this is only a problem if we support "Response Shape" parsing. In pseudo-Java, the above would need to produce something like: interface Query {
interface Pets {
// Is this Integer or Float?
?? value();
}
Pet pets();
} This is probably not a problem if you parse into either Type Models or Fragment Models, but those require adding meta-fields like |
thanks @mjmahone for highlighting the need to parse the response unambiguously. This was the missing point to rationale the current logic. {pets {
... on Cat {
friend: catFriend {
catFriendName
}}
... on Dog {
friend: dogFriend {
dogFriendName
}}
}} can be represented by one model where |
The current spec rule for overlapping rules allows the following:
Query:
Schema:
This query is allowed because
friend
can't never be executed at the same time because the fragment types are both different Object types and and execution time only one Fragment can be therefore valid.The
friend
results will have two different "shapes" depending on if it is aCat
orDog
: One hasdogFriendName
, the othercatFriendName
.But the following query is not allowed (same schema as above):
The reason for that is that
catValue
isInt
butdogValue
isFloat
and the current rule doesn't allow it.Different object shapes are already allowed: should the spec allow for more diverging?
The suggestion is to never compare the different result types for fields which can never executed at the same time and therefore allow the second query above.
I would also be interested in the historical context: the current rule was modified in this PR #120. @leebyron do you have maybe an explanation reasoning for the current rule?
The text was updated successfully, but these errors were encountered: