Files
nest/sample/32-graphql-federation-schema-first
Kamil Mysliwiec 6620c431ea Merge pull request #16192 from nestjs/renovate/node-24.x
chore(deps): update dependency @types/node to v24.10.8
2026-01-14 19:59:32 +01:00
..
2023-02-10 21:39:29 -05:00

GraphQL Federation - Schema First

A simple example of GraphQL Federation using Schema First approach.

Execution

Make sure to start the two sub-graph applications first, then the gateway. Otherwise the gateway won't be able to fetch schemas from the sub-graphs.

cd users-application && npm run start
cd posts-application && npm run start
cd gateway && npm run start

Access the graph

You can reach the gateway under http://localhost:3002/graphql

Query a combined graph

query getUserWithPosts($userId: ID!) {
  getUser(id: $userId) {
    id
    name
    posts {
      authorId
      id
      title
    }
  }
}