GraphQL Schema Federation With Apollo, TypeScript and Node.js

Let’s build a single data graph that aggregates multiple services

Nuno Brites
The Startup

--

In this article, we will use Apollo federation to build a single data graph across multiple services.

Each service will have a unique schema that relates to its own domain and there will be a gateway that will be responsible for composing the distinct schemas into a federated data graph and by executing the queries against the multiple services.

Schema Federation Diagram

We will be implementing schema federation for a media content platform and will have the following services: Contentand Review. The tech stack will be composed by Apollo Server as the GraphQL server, with TypeScript as the programming language, and Node.js as runtime.

Before we dive into the code let’s set up the project and understand which packages will be used and their purpose.

Project Setup

Let’s start by creating the Node.js project and install some of the packages that will help us build the multiple services and gateway.

--

--

Nuno Brites
The Startup

Software engineer driven by curiosity, writing about software development and tech ✏️ 🚀