I’m working to migrate from one system to another, and as such my entities have two primary keys, one is a reference to the new system, and the second is a reference to the old system.
type User @key(fields: "oldId") @key(fields: "newId") {
oldId: ID!
newId: ID!
}
Some of our subgraphs are able to resolve based on only the old id, others off of only the new id, and others off of either. I was under the impression that the entity definition had to match across all subgraphs, but I’ve seen now that that is not the case. Subgraphs can disagree about which fields are keys.
So my question is: what are the ramifications of subgraphs disagreeing? Will I run into problems if one subgraph declares @key(fields: "oldId")
and another doesn’t declare that key? Can a subgraph resolve out entities with a different subgraphs key if it doesn’t know that it considers that a key?
For instance if I declare
type User @key(fields: "oldId") {
oldId: ID!
newId: ID!
}
and then resolve
return {
__typename: "User",
newId: "SomeUUID"
}
Is that legal? Will the next subgraph in the query plan be able to resolve off of that if it declares newId
as a key? Should I always resolve out the id that I know about?
What happens if I query for a field that @requires(fields: "oldId")
but the initial subgraph didn’t resolve it? Will it hit some other subgraph to find it?