You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Subgraph schemas opt in to Federation v2 features by applying the `@link` directive to the `schema` type. You can optionally add an `import` list to this definition to include each federation-specific directive that the subgraph schema uses. In the example below, the schema uses the `@key` and `@shareable` directives:
Apollo Federation defines a collection of directives that you use in your subgraph schemas to enable certain features.
11
12
@@ -73,6 +74,8 @@ type Book @fed__shareable {
73
74
74
75
As shown, custom namespace prefixes also end in two underscores.
75
76
77
+
## Managing schemas
78
+
76
79
<MinVersionversion="2.0">
77
80
78
81
### The `@link` directive
@@ -90,6 +93,8 @@ directive @link(
90
93
91
94
Thisdirectivelinksdefinitionsfromanexternalspecificationtothisschema. Every Federation 2 subgraph uses the `@link` directive to import the other federation-specific directives described in this article (see the syntax in [Importing directives](#importing-directives)).
92
95
96
+
<LinkDirective />
97
+
93
98
For more information on `@link`, see the [official spec](https://specs.apollo.dev/link/v1.0/).
Copy file name to clipboardexpand all lines: docs/source/reference/federation/subgraph-spec.mdx
+7
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@ subtitle: Subgraph specification reference for server library developers
4
4
description: Learn about Apollo Federation 2 subgraph specifications, enhanced introspection, and entity field resolution for GraphQL server libraries.
This content is provided for developers adding federated subgraph support to a GraphQL server library, and for anyone curious about the inner workings of federation. You do not need to read this if you're building a supergraph with existing [subgraph-compatible libraries](/graphos/reference/federation/compatible-subgraphs), such as Apollo Server.
8
10
9
11
Servers that are partially or fully compatible with this specification are tracked in Apollo's [subgraph compatibility repository](https://github.com/apollographql/apollo-federation-subgraph-compatibility).
@@ -13,6 +15,7 @@ For a GraphQL service to operate as an Apollo Federation 2 subgraph, it must do
13
15
- Automatically extend its schema with all definitions listed in [Subgraph schema additions](#subgraph-schema-additions)
14
16
- Correctly resolve the `Query._service`[enhanced introspection field](#fetch-service-capabilities)
15
17
- Provide a mechanism for subgraph developers to resolve entity fields via the [`Query._entities` field](#resolving-entity-fields-with-query_entities)
18
+
- Apply the [`@link` directive to the `schema` type](#apply-link-directive)
16
19
17
20
Each of these requirements is described in the sections below.
18
21
@@ -408,6 +411,10 @@ For this reference resolver, the developer calls a `fetchProductByUPC` function,
408
411
409
412
Your subgraph library does not need to use this reference resolver pattern. It just needs to provide and document some pattern for defining entity-fetching logic.
410
413
414
+
## Apply @link directive
415
+
416
+
<LinkDirective />
417
+
411
418
## Glossary of schema additions
412
419
413
420
This section describes type and field definitions that a valid subgraph service must automatically add to its schema. These definitions are all listed above in [Subgraph schema additions](#subgraph-schema-additions).
0 commit comments