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
`Key Field(s) '[id]' are not queried on X2 at Operation(XQuery).union`
I found a workaround. By modifying the Query as follows, the error disappears.
queryXQuery {
x {
...onX1 {
idname
}
...onX2 {
id
}
}
}
Logs
Key Field(s) '[id]' are not queried on X2 at Operation(XQuery).union
The text was updated successfully, but these errors were encountered:
sonatard
changed the title
Key Field(s) '[id]' are not queried on XUnion at Operation(YQuery).union
Key Field(s) '[id]' are not queried on XUnion at Operation(XQuery).union
Aug 10, 2023
The reason this error is thrown is because we can't add id on an union field:
queryXQuery {
x {
# This does not validate as no field except __typename can be queried on unionsid...onX1 {
name
}
}
}
We could add fragments that query id on all types automatically:
queryXQuery {
x {
# fragments added by the Apollo compiler...onX1 {
id
}
...onX2 {
id
}
# etc... if more types in the union # original fragment ...onX1 {
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
The text was updated successfully, but these errors were encountered: