Apply @shareable, @override, @inaccessible, understand composition rules, and how the supergraph is produced and consumed by the Apollo Router.
0 / 5 completed
1 / 5
What does the @shareable directive do in Apollo Federation v2?
@shareable: in Federation v1, types with the same name were implicitly shared. In v2, each type is owned by one subgraph by default. Adding @shareable on a field (e.g. name: String @shareable) explicitly declares that multiple subgraphs can resolve it, allowing the router to fetch it from whichever subgraph answers the query.
2 / 5
What does the @override directive accomplish in Federation v2?
@override: when migrating the Product.stockCount field from the inventory subgraph to the products subgraph, add stockCount: Int @override(from: "inventory") in the products subgraph schema. The router sends stockCount queries to products. The inventory subgraph can still serve the field until its schema is updated, enabling zero-downtime migrations.
3 / 5
What does the @inaccessible directive mark in the supergraph schema?
@inaccessible: a subgraph may expose an internal ID field used to join types across subgraphs but not intended for clients. Marking it @inaccessible keeps it in the composed schema for the router's query planning while hiding it from the client-facing introspection. This enables clean federation key joins without polluting the public API.
4 / 5
What are composition rules in Apollo Federation v2 and when does composition fail?
Composition rules: the rover supergraph compose command validates all subgraph schemas together. Common composition errors: two subgraphs define Product.price differently without @shareable; an @key(fields: "sku") entity has no __resolveReference; a @provides directive references a field that isn't declared in the providing subgraph's schema.
5 / 5
What is the supergraph in Apollo Federation v2 and how is it produced?
Supergraph:rover supergraph compose --config supergraph.yaml fetches all registered subgraph schemas and produces a supergraph SDL. The Apollo Router loads this SDL to understand the full type system and compute query plans. Clients query a single GraphQL endpoint; the router handles subgraph fan-out and result merging transparently.