I am migrating a large, complex schema to federation, and have encountered a scenario with Interfaces and resolving field data across subgraphs I’m not sure how to solve.
Games subgraph
interface Game {
id: ID!
sport: String!
}
type BasketballGame implements Game @key(fields: "id") {
id: ID!
sport: String!
}
Feed subgraph
interface Consumable {
id: ID!
type: String!
}
extend type BasketballGame implements Consumable @key(fields: "id") {
id: ID! @external
type: String!
}
extend type Query {
feed(user_id: ID!): [Consumable!]!
}
I’d like to be able to use a @provides
directive approach to tell the Feed subgraph it can resolve the sport field, however I don’t have a concrete type to annotate. I know I could handle this so that the feed
query gets the game data from the game subgraph, but it would be trivial for the feed
query to return at least the base level Game
fields itself so performance wise that is less optimal. I could add a FeedGame
interface in the Feed subgraph and add that as an interface the BasketballGame
type implements but that would break existing queries.
I’m still coming to grips with Federated schemas so perhaps I’m missing something, thanks.