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
When a query aliases a field on a fetched entity to the same name as the key of the entity, the server starts to return the wrong data if the query is modified to include fields joined from multiple subgraphs. That's a bit wordy, but I'll break up the reproduction sample here.
Subgraph one defines the entity as:
type Query {
object: O
}
type O @key(fields: "id") {
id: ID!
legacyId: ID
a: String
}
Then we have a rather simple query here, which uses the legacyId and not the id that is the entity's key. The legacyId is aliased to id which matches the entity's key.
query TestQuery {
object {
id: legacyId
legacyId # Not necessary but used later to focus attention to the issue
a
}
}
At this point, everything is fine. Given the following resolver:
cltnschlosser
changed the title
Query returns incorrect data when there is a conflict between query field alias and entity id
Query returns incorrect data when there is a conflict between query field alias and entity key field
Jun 16, 2024
Issue Description
When a query aliases a field on a fetched entity to the same name as the key of the entity, the server starts to return the wrong data if the query is modified to include fields joined from multiple subgraphs. That's a bit wordy, but I'll break up the reproduction sample here.
Subgraph one defines the entity as:
Then we have a rather simple query here, which uses the legacyId and not the id that is the entity's key. The legacyId is aliased to
id
which matches the entity's key.At this point, everything is fine. Given the following resolver:
We end up with the expected result:
Notice id and legacyId are the same (because id is just an alias).
When we introduce a second subgraph that extends this entity, complications arise.
Modifying our test query to include the new field
b
:Results in the unexpected:
id
andlegacy
no longer match, insteadid
is replaced with the actualid
field and the alias is now longer functioning.Link to Reproduction
#3035
Reproduction Steps
No response
The text was updated successfully, but these errors were encountered: