What is Apollo Federation v2 and how does the supergraph work?
Answer
Apollo Federation v2 is the industry standard for composing multiple GraphQL services (subgraphs) into a single unified API (supergraph). Architecture: each team owns a subgraph with its own schema and resolvers; the Apollo Router (Rust-based gateway) receives client queries, runs the query planner to determine which subgraphs to call and in what order, executes the plan (potentially fetching from multiple subgraphs in parallel), and merges results. Key directives: @key(fields: "id") (entity primary key — enables cross-service entity resolution), @shareable (field can be defined in multiple subgraphs), @override(from: "SubgraphName") (migrate field ownership between subgraphs), @provides/@requires (optimize resolver execution by pre-providing fields). Schemas are composed with the Rover CLI. Apollo GraphOS manages schema checks, schema registry, and usage analytics.
Previous
How do you implement field-level caching with cache hints in GraphQL?
Next
How do you implement entity resolution in Apollo Federation?
More GraphQL Questions
View all →- Advanced How do you implement entity resolution in Apollo Federation?
- Advanced What are the security vulnerabilities specific to GraphQL?
- Advanced How does the GraphQL query planning and execution pipeline work?
- Advanced What is the @defer and @stream directive and how do they work?
- Advanced How do you design a scalable GraphQL schema?