-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
The current spec rule for overlapping rules allows the following:
Query:
{pets {
... on Cat {
friend: catFriend {
catFriendName
}}
... on Dog {
friend: dogFriend {
dogFriendName
}}
}}Schema:
type Query {
pets: Pet
}
interface Pet {
name: String
}
type Cat implements Pet {
name: String
catValue: Int
catFriend: CatFriend
}
type CatFriend {
catFriendName: String
}
type Dog implements Pet {
name: String
dogValue: Float
dogFriend: DogFriend
}
type DogFriend {
dogFriendName: String
}
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 a Cat or Dog: One has dogFriendName, the other catFriendName.
But the following query is not allowed (same schema as above):
{pets {
... on Cat {
value: catValue
}
... on Dog {
value: dogValue
}
}}The reason for that is that catValue is Int but dogValue is Float 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?