API / Apollo Gateway Interview questions
What is a subgraph in Apollo Federation?
A subgraph is an individual GraphQL service that owns a specific slice of the overall graph — for instance a Products service or a Reviews service. Each one exposes its own schema, annotated with federation directives such as @key, and can be built, tested, and deployed independently of every other subgraph.
At composition time the gateway or router fetches each subgraph's schema definition and merges them into a supergraph. At request time, it forwards only the relevant portion of a client's query to the subgraph(s) that actually own those fields, using ordinary GraphQL-over-HTTP calls.
Because each subgraph is a normal GraphQL server under the hood (typically built with a library like @apollo/subgraph), a team can adopt federation without rewriting how they write resolvers.
More Related questions...