skip to content

Federation & Composition

Many service schemas composed into one client-facing graph under Apollo Federation — a specification of its own, not part of GraphQL's. Interviewers raise it wherever GraphQL meets microservices.

part ofGraphQLoverview, primer and where to startread it →
on this pageshow

questions

page 2 of 2

Which federation schema do you diff for client-breaking changes before a subgraph deploys?

level: seniorimportance: should knowfreq 46%

basics

~20 s

Diff the API schema, because that is the only document consumers see. A subgraph SDL diff misses changes the other subgraphs decide, and a supergraph diff is full of routing churn that never reaches a client.

open as a page

How do you decide whether a company runs one GraphQL graph or several?

level: principalimportance: should knowfreq 43%

basics

~20 s

Decide on audience and traversal, not tidiness. One graph earns its cost only where real client operations cross domains. Separate graphs are right when audiences, cadences or trust boundaries differ, or nobody can staff the platform a shared graph needs.

open as a page

How do you decide which subgraph should own a field so that query plans stay shallow?

level: principalimportance: should knowfreq 34%

basics

~20 s

Start from the hot operations, not the schema. Place a field where the traffic that matters reaches it in the fewest dependent hops, and treat ownership as a team decision with a real migration cost.

open as a page

When would you keep a working stitched GraphQL gateway instead of moving to composition?

level: principalimportance: should knowfreq 39%

basics

~20 s

Keep it when the mapping is edited rarely by the people who own the services, when some merged schemas are not yours to change, or when you rely on gateway transforms composition cannot express. Move when it becomes a cross-team queue.

open as a page

Where should authorization live in a federated graph — the router, each subgraph, or the services behind them?

level: principalimportance: should knowfreq 36%

basics

~20 s

Split it by what each layer can know. A router has the credential, the document and the schema but no data, so it can only enforce coarse rules. Per-record rules must live in the subgraph or below.

open as a page

In a federated graph with many services, which subgraph failures should be allowed to fail a whole request?

level: principalimportance: should knowfreq 38%

basics

~20 s

Only the ones whose absence would make the rest of the response wrong or unsafe to act on. Everything else degrades to a hole. Tier the subgraphs by that test, then encode each tier in nullability, budgets and the client contract.

open as a page

Why are federation's _entities and _service named with one underscore rather than two?

level: juniorimportance: nice to knowfreq 17%

basics

~20 s

The GraphQL specification reserves the double-underscore prefix for the introspection system and forbids schema authors from using it. Federation is a layer built on ordinary GraphQL, so its added members take a single underscore instead — legal, and conventionally set aside for machinery.

open as a page

In a Federation 1 subgraph schema, what does the extend keyword on a type mean?

level: juniorimportance: nice to knowfreq 24%

basics

~20 s

The extend keyword marks the type as owned by another subgraph: this schema only contributes extra fields to a type it did not define, so composition treats the two declarations as one type rather than a clash.

open as a page

In Apollo Federation, how does composition merge an enum that two subgraphs define with different values?

level: middleimportance: nice to knowfreq 28%

basics

~20 s

It depends where the enum is used. Federation 2 takes the union for an enum used only in output positions, the intersection for one used only in input positions, and exact agreement when it is used both ways.

open as a page

When a federation router builds one _entities call, why does it deduplicate representations?

level: middleimportance: nice to knowfreq 26%

basics

~20 s

Because a list usually names the same entity many times: 143 artworks by 37 artists yield 37 distinct keys. Sending each key once cuts payload and subgraph work. It is a router optimization, not a rule the federation specification imposes.

open as a page

Why does a federation router add fields to a subgraph fetch that nobody selected?

level: middleimportance: nice to knowfreq 26%

basics

~20 s

Because the next step has to be addressable. Into each fetch the router injects __typename and the key fields of any object whose remaining fields another subgraph owns, then strips those values back out before serialising the response.

open as a page

How does a stitched GraphQL gateway resolve a field whose data lives in another service?

level: middleimportance: nice to knowfreq 27%

basics

~20 s

The gateway becomes a client of that service. It resolves the parent first, then builds a brand-new document against the second service using values from that parent as arguments, and grafts the result into the response tree.

open as a page

When would a subgraph declare @key(fields: "id", resolvable: false) on a type?

level: middleimportance: nice to knowfreq 26%

basics

~20 s

When the subgraph only points at the entity and cannot look one up. It declares the identity so its own fields can reference the object, while telling composition never to route key lookups for that type here.

open as a page

showing 31–43 of 43