Skip to content

Commit

Permalink
update doc with flag
Browse files Browse the repository at this point in the history
  • Loading branch information
meskill committed Sep 26, 2024
1 parent 32de14b commit 7217667
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/apollo-federation-subgraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions docs/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7217667

Please sign in to comment.