Documentation Index
Fetch the complete documentation index at: https://wundergraphinc-ondrej-eng-7122-delete-client.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Definition
Overview
The@external directive declares that a field is not independently resolvable by the current subgraph. The exact behavior depends on where the field is referenced:
- Unresolvable by this subgraph — An
@externalfield referenced only in a@requiresFieldSet, or defined only to satisfy an interface. The router will never consider this subgraph to resolve it. The field is defined locally so that@requirescan reference it in itsFieldSetor to satisfy an interface contract. - Conditionally resolvable by this subgraph — An
@externalfield referenced in a@providesFieldSet. The subgraph can resolve this field, but only at specific query paths where@providesis applied. At all other paths, the router fetches it from another subgraph.
@external field must be referenced in @key, @provides, and/or @requires, or defined to satisfy an interface. If it is not used in any of these ways, composition will reject the schema. Every @external field must also have a non-external counterpart: the same field defined without @external in at least one other subgraph.
In most schemas, @external only appears on entity types (types with a @key directive), where fields come from multiple subgraphs.
Field-Level Declaration
When applied to a single field definition,@external marks only that field as coming from another subgraph. In this example, two subgraphs contribute to the Event entity: the “scheduling” subgraph resolves capacity and registrationCount, while the “waitlist” subgraph needs those values to compute spotsRemaining and therefore declares them @external:
capacity and registrationCount are declared here only so that @requires can reference them. The router will still fetch their values from the scheduling subgraph.
Object-Level Declaration
Applying@external to an object type marks all fields currently defined on that type as external:
@external individually. It is typically used when a subgraph needs to reference a complete object type resolved by another subgraph.
Behavior at Composition
External fields are excluded from the subgraph’s contribution to the composed supergraph schema. They exist in the subgraph’s SDL only to support directives that reference them. The router knows which subgraph resolves the field and will fetch it from there. If a field is declared@external in one subgraph but is never defined (without @external) in any other subgraph, composition will fail.
Key Fields and @external
Key fields (those listed in @key(fields: "...")) are implicitly shareable across subgraphs and do not need @external. If a subgraph only needs to reference an entity without resolving any of its fields, use resolvable: false on the @key instead of adding @external to each field:
See Also
@key designates an object type as a federation entity. @requires uses external fields to declare dependencies for a locally-resolved field. @provides declares that external fields can be resolved at a specific query path.