Open sonatard opened 1 year ago
Hi 👋
The reason this error is thrown is because we can't add id
on an union field:
query XQuery {
x {
# This does not validate as no field except __typename can be queried on unions
id
... on X1 {
name
}
}
}
We could add fragments that query id
on all types automatically:
query XQuery {
x {
# fragments added by the Apollo compiler
... on X1 {
id
}
... on X2 {
id
}
# etc... if more types in the union
# original fragment
... on X1 {
name
}
}
}
But we have always resisted doing so because it felt like a larger modification of the user query that could be surprising.
Do you think adding the fragments automatically would help in that case?
Version
3.8.2
Summary
I have set the
extend interface Node @typePolicy(keyFields: "id")
.And when I build, the following error occurs.
Key Field(s) '[id]' are not queried on X2 at Operation(XQuery).union
Steps to reproduce the behavior
I found a workaround. By modifying the Query as follows, the error disappears.
Logs
Key Field(s) '[id]' are not queried on X2 at Operation(XQuery).union