⬡ GraphQL Advanced

What is schema composition and conflict detection in Apollo Federation?

Answer

Schema composition in Apollo Federation is the process by which the Apollo Router (or Apollo Studio) merges all subgraph schemas into a single unified supergraph SDL. Composition applies semantic rules to detect conflicts and validate that the merged schema is coherent. Composition errors include: two subgraphs defining the same type with incompatible fields, an @key referencing fields that do not exist, or type extensions for non-existent base types. Composition succeeds only when all rules pass. The schema registry in Apollo Studio stores each subgraph's schema versioned by deployment. The rover subgraph check CLI command runs composition and breaking change detection against all registered client operations in CI, failing the pipeline if the proposed change would break any active client. This creates a safe, automated governance layer that prevents incompatible subgraph deployments from reaching production.