From a1534072d1cae1acc0d6e5b416fc496f3cd3d5c4 Mon Sep 17 00:00:00 2001 From: aidan coyne Date: Thu, 22 Sep 2022 09:59:01 -0500 Subject: [PATCH] add documentation about enabling link directive --- docs/en/src/apollo_federation.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/en/src/apollo_federation.md b/docs/en/src/apollo_federation.md index ac03643a..6f8b7f7d 100644 --- a/docs/en/src/apollo_federation.md +++ b/docs/en/src/apollo_federation.md @@ -20,6 +20,26 @@ - The `override` directive is used to indicate that a field is now to be resolved by the current subgraph instead of the named subgraph. +- The `link` directive is needed in order to indicate that the subgraph is Federation v2 compatible, enabling the `shareable`, `inaccessable`, and `override` directives. + +## Enabling Federation v2 using the link directive + +async-graphql provides a configuration function `enable_apollo_fed2_link` on the schema builder to have it print out an `extend schema` element with an appropriately configured `link` directive whenever the federation schema is requested. + +```rust +Schema::build(Query, EmptyMutation, EmptySubscription) + .enable_apollo_fed2_link() + .finish() +``` + +and the following (or similar) will be attached to the schema: +``` +extend schema @link( + url: "https://specs.apollo.dev/federation/v2.0", + import: ["@key", "@tag", "@shareable", "@inaccessible", "@override", "@external", "@provides", "@requires"] +) +``` + ## Entity lookup function ```rust