The results of your query can still contain Authors even if they won’t contain any fields.
If you have configured the cache to use id as the key field for Author, then this field is needed and must be queried so the cache can use it. In most cases, id fields are automatically added to queries in a transparent way. But in cases like this one with unions, this cannot be done automatically.
One way to fix this is to add a case for Author too:
edges {
node {
... on Article {
id
}
... on Author {
id
}
}
}
When using an alias like you do, the server will not reply with an id but with authorId, which means the id cannot be seen and used in the key, and therefore Apollo will still complain it is missing. Why can’t you use id directly?
Hello,
You are right, it works.
I have an issue with our schema, some id fields are nullable and some non nullable.
I will update our schema to get consistent id non nullability.
Thanks !