API / Apollo Gateway Interview questions
What are the main directives used in Apollo Federation?
Federation relies on a small set of schema directives to describe how types and fields relate across subgraphs. The main ones are:
- @key – marks the field(s) that uniquely identify an entity.
- @external – declares that a field is defined in another subgraph, used alongside @requires/@provides.
- @requires – says a field needs another field from the entity's owning subgraph to compute its own value.
- @provides – says a field can supply certain fields of a related entity directly, avoiding an extra round trip.
- @shareable – marks a field as intentionally resolvable by more than one subgraph (Federation 2).
- @override – migrates ownership of a field from one subgraph to another (Federation 2).
- @inaccessible – hides a field from the public schema while keeping it usable internally.
- @tag – labels fields/types for use with GraphOS contracts.
Not every subgraph uses all of these — most schemas lean mainly on @key, and reach for the rest only when a specific cross-subgraph relationship calls for it.
More Related questions...