APIs

Apollo Federation

Federation helps companies implement GraphQL at scale and allows you to combine multiple GraphQL APIs (subgraphs) into a single Supergraph. WunderGraph has native support for Apollo federation, it supports Queries, Mutations as well as Subscriptions.

It brings a lot of useful features to implement Graphs across multiple teams in a "federated" way, hence the name. It was invented and specified by Apollo .

WunderGraph is extremely fast executing GraphQL Operations and is therefore a great fit for a Federation Gateway.

Add a Apollo Federation DataSource

To add a Apollo Federation data source, edit .wundergraph/wundergraph.config.ts and introspect the SubGraphs like the config below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { configureWunderGraphApplication, introspect } from '@wundergraph/sdk';
const federatedApi = introspect.federation({
apiNamespace: 'federated',
upstreams: [
{
url: 'http://localhost:4001/graphql',
},
{
url: 'http://localhost:4002/graphql',
},
{
url: 'http://localhost:4003/graphql',
},
{
url: 'http://localhost:4004/graphql',
},
],
});
configureWunderGraphApplication({
apis: [federatedApi],
});

Simply add all the URLs of your SubGraphs to the upstreams array.

Learn more

Guides

How to write GraphQL and TypeScript operations.

Reference docs

All Federation introspection options.

Previous
GraphQL

Was this article helpful to you?
Provide feedback

Edit this page