API / Apollo Gateway Interview questions
What is the difference between @shareable and @override?
Both are Federation 2 directives, but they solve different problems.
| @shareable | @override |
| Declares a field is intentionally resolvable by more than one subgraph at the same time | Declares a field's ownership has moved from one subgraph to another |
| Used for fields that genuinely make sense to compute in multiple places (e.g. a cheap derived value) | Used during migrations, when a field is being relocated to a new service |
| Both subgraphs keep resolving the field long-term | The old subgraph's definition is effectively retired once the override takes effect |
A useful way to remember it: @shareable is a permanent, deliberate design choice; @override is a temporary-to-permanent handoff during a migration, letting you move a field between services without a synchronized deploy or downtime.
More Related questions...