🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@apollo/gateway

Package Overview
Dependencies
Maintainers
1
Versions
358
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apollo/gateway

Apollo Gateway

2.11.2
latest
Source
npm
Version published
Weekly downloads
280K
6.19%
Maintainers
1
Weekly downloads
 
Created

What is @apollo/gateway?

@apollo/gateway is a package that allows you to build a federated data graph by composing multiple GraphQL services into a single unified API. It is part of Apollo's Federation architecture, which enables you to manage and scale your GraphQL services independently while providing a seamless experience for clients.

What are @apollo/gateway's main functionalities?

Creating a Gateway

This code sample demonstrates how to create an Apollo Gateway that composes multiple GraphQL services into a single unified API. The `serviceList` array contains the list of services to be federated.

const { ApolloGateway } = require('@apollo/gateway');
const { ApolloServer } = require('apollo-server');

const gateway = new ApolloGateway({
  serviceList: [
    { name: 'accounts', url: 'http://localhost:4001' },
    { name: 'products', url: 'http://localhost:4002' },
    { name: 'reviews', url: 'http://localhost:4003' }
  ]
});

const server = new ApolloServer({ gateway, subscriptions: false });

server.listen().then(({ url }) => {
  console.log(`🚀 Server ready at ${url}`);
});

Customizing Service Health Checks

This code sample shows how to enable service health checks in Apollo Gateway. The `serviceHealthCheck` option ensures that the gateway periodically checks the health of the federated services.

const { ApolloGateway } = require('@apollo/gateway');
const { ApolloServer } = require('apollo-server');

const gateway = new ApolloGateway({
  serviceList: [
    { name: 'accounts', url: 'http://localhost:4001' },
    { name: 'products', url: 'http://localhost:4002' },
    { name: 'reviews', url: 'http://localhost:4003' }
  ],
  serviceHealthCheck: true
});

const server = new ApolloServer({ gateway, subscriptions: false });

server.listen().then(({ url }) => {
  console.log(`🚀 Server ready at ${url}`);
});

Using Managed Federation

This code sample demonstrates how to use managed federation with Apollo Gateway. The `experimental_pollInterval` option allows the gateway to periodically poll for updates to the federated services' schemas.

const { ApolloGateway } = require('@apollo/gateway');
const { ApolloServer } = require('apollo-server');

const gateway = new ApolloGateway({
  serviceList: [
    { name: 'accounts', url: 'http://localhost:4001' },
    { name: 'products', url: 'http://localhost:4002' },
    { name: 'reviews', url: 'http://localhost:4003' }
  ],
  experimental_pollInterval: 10000
});

const server = new ApolloServer({ gateway, subscriptions: false });

server.listen().then(({ url }) => {
  console.log(`🚀 Server ready at ${url}`);
});

Other packages similar to @apollo/gateway

Keywords

graphql

FAQs

Package last updated on 25 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts