Closed kamilkisiela closed 2 months ago
The least intrusive (least amount of aliasing) method I could think of would be to compare selection sets of GatherPlanResolver
, as it is really the only place where the type collision can happen.
We need to detect fields that are not mergeable (according to https://spec.graphql.org/draft/#FieldsInSetCanMerge()).
For that we need to store types of fields, like types: { [<subgraph name>]: <type as string>}
.
Once we find them, we apply aliases. We could adopt some logic here, like to leave the first field occurrence untouched, but rename every other field that has a different output type, or we could pick the one that is used the least. Honestly, I don't think it matters that much... so we could apply a simple algorithm here (alias fields based on type, basically group them).
https://federation-compatibility.the-guild.dev/entity-and-no-entity/subgraphs
A
B
Given these two subgraphs, when running the following query:
We hit a GraphQL error because
User.id
has a non-nullable output typeID!
, butAdmin.id
resolvesID
.I think the only solution here is to apply an alias on conflicting fields.