API / Apollo Gateway Interview questions
How does the @external directive work?
@external declares that a field is actually owned and defined by another subgraph, and this subgraph is only referencing it — typically because it needs that field's value as an input to @requires, or is supplying it via @provides.
type Product @key(fields: "id") { id: ID! weight: Float! @external shippingEstimate: Float! @requires(fields: "weight") }
Here, the Shipping subgraph doesn't own weight — it's marked @external to tell composition "I know this field exists elsewhere, don't treat my declaration of it as a conflicting definition." The gateway fetches weight from the owning subgraph first, then passes it along so Shipping can compute shippingEstimate.
In Federation 2, many former uses of bare @external have been narrowed since @shareable now covers the simple "resolved in more than one place" case more explicitly.
More Related questions...