From 721766714e590ddc119b4d9a8e64f3184ec271fc Mon Sep 17 00:00:00 2001 From: meskill <8974488+meskill@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:10:40 +0000 Subject: [PATCH] update doc with flag --- docs/apollo-federation-subgraph.md | 8 ++++++++ docs/directives.md | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/docs/apollo-federation-subgraph.md b/docs/apollo-federation-subgraph.md index 833931cc76..6eadc991a4 100644 --- a/docs/apollo-federation-subgraph.md +++ b/docs/apollo-federation-subgraph.md @@ -13,6 +13,10 @@ First, you need to create a basic Tailcall configuration. For reference, check o ## Define Entity Resolvers +:::note +Skip this step if you don't have entities for now or want to add them later. +::: + Now you need to add [entity resolvers](https://www.apollographql.com/docs/federation/entities/) to the Tailcall config to make it act as a subgraph. To do this, you need to define resolver on types by using one of the [directives](./configuration.mdx) that resolve the data. Use [`{{.value}}`](https://tailcall.run/docs/graphql-resolver-context-tailcall/#value) to access the fields that act as a federation `@key` and will be provided by the Federation Router when making the request to this subgraph. @@ -34,6 +38,10 @@ type Post Please, note that you don't need to specify the `@key` directive manually when defining entity resolver with Tailcall. It's because Tailcall can automatically infer the key definitions from the usage of the resolver itself. ::: +## Enable federation in the Tailcall config + +Federation is controlled by the flag [`enableFederation`](./directives.md#enablefederation). In case you've added the entity resolvers on the previous step then federation compatibility will be enabled even without the flag. + ## Register your subgraph Registration of the subgraph depends on what Federation Router you use. diff --git a/docs/directives.md b/docs/directives.md index 8cda223903..1dd6037b37 100644 --- a/docs/directives.md +++ b/docs/directives.md @@ -1713,6 +1713,14 @@ schema @server(routes: {graphQL: "/tailcall-gql", status: "/health"}) In this example, the GraphQL endpoint is changed to `/tailcall-gql` and the status endpoint to `/health`. +### enableFederation + +A boolean flag, if set to `true` the Tailcall server will additionally act as federation subgraph. If set to `false` federation compatibility will be forcefully disabled. If flag is not set the federation compatibility is enabled automatically if any entity resolver is defined and disabled otherwise. + +```graphql showLineNumbers +schema @server(enableFederation: true) +``` + ## @telemetry Directive The `@telemetry` directive facilitates seamless integration with [OpenTelemetry](https://open-telemetry.io), enhancing the observability of your GraphQL services powered by Tailcall. By leveraging this directive, developers gain access to valuable insights into the performance and behavior of their applications.