Skip to main content
Version: v2.x

Apollo Federation Support

Introduction

Hasura GraphQL Engine supports the Apollo Federation v1 spec, so you can add Hasura as a subgraph in your Apollo federated gateway. You can also use Hasura generated table types in your other subgraphs by enabling tables for Apollo Federation explicitly.

Supported from

Apollo Federation is available from Hasura version v2.10.0 and above.

Enabling apollo-federation

Apollo Federation can be enabled using the server configuration (--enable-apollo-federation flag or setting HASURA_GRAPHQL_ENABLE_APOLLO_FEDERATION to true).

For backwards compatibility, the feature can also be enabled by adding apollo_federation to the HASURA_GRAPHQL_EXPERIMENTAL_FEATURES environment variable array or with the server flag --experimental-feature.

Using Hasura tables in other subgraphs

Currently, only the types generated for the database source tables can be extended in other subgraphs. The primary key will be used in the @key directive's fields argument. For example, enabling the table user for Apollo Federation will generate the type user as follows:

type user @key(fields: "id") {
id: Int!
name: String
...
}

The Apollo Federation support in Hasura only allows extending other subgraphs with Hasura types. The other way i.e. extending Hasura types with other subgraphs is not possible currently. We recommend using remote relationships for extending types from other subgraphs in Hasura.

Supported types

Other types such as action types, Remote Schema types, etc. cannot be extended to other subgraphs.

Prerequisite before enabling Apollo Federation on the Hasura Console

To enable Apollo Federation using the Hasura Console, you'll first need to add apollo_federation to the list of experimental features using the HASURA_GRAPHQL_EXPERIMENTAL_FEATURES environment variable array or with the server flag --experimental-feature. You can learn more about setting these here.

Head to the Data -> [table-name] -> Modify tab in the Console and toggle the switch in the Enable Apollo Federation section:

Set table as enum