Files
nest/sample/31-graphql-federation-code-first
Kamil Mysliwiec ad3f777a3c Merge pull request #13236 from nestjs/dependabot/npm_and_yarn/sample/31-graphql-federation-code-first/gateway/ip-2.0.1
chore(deps): bump ip from 2.0.0 to 2.0.1 in /sample/31-graphql-federation-code-first/gateway
2024-02-23 09:06:22 +01:00
..
2024-02-20 21:43:08 +00:00
2024-02-20 21:43:09 +00:00

GraphQL Federation - Code First

A simple example of GraphQL Federation using Code 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:3001/graphql

Query a combined graph

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