console/packages/services/external-composition/federation-2
2026-03-14 11:12:51 +01:00
..
src run integration tests locally against local running services (#5096) 2024-07-15 11:21:23 +00:00
.env.template run integration tests locally against local running services (#5096) 2024-07-15 11:21:23 +00:00
package.json chore: bump vulnerable dependencies (#7847) 2026-03-14 11:12:51 +01:00
README.md Use graphql-hive/<service> docker images and update repo refs (#5672) 2024-10-14 16:36:45 +02:00
tsconfig.json Enhancement/hive lab lib (#7697) 2026-03-06 22:37:08 +01:00
turbo.json chore: add dev:hive script using turbo (#7053) 2025-09-26 20:21:17 +09:00

Composition Service for Apollo Federation 2

Background

Hive comes with support for Apollo Federation v2, based on external composition.

This package provides a reference for running external composition as a NodeJS service, on your local infrastructure, and connect GraphQL Hive (Cloud or self-service).

Usage

Start by deciding on your encryption secret. This is needed in order to ensure you endpoint is secured and can be triggered only by Hive platform. Your secret can be any string you decide, and it will be used as private key to hash the requests to your composition service.

We are going to use that secret later as SECRET env var, and also in Hive dashboard.

Running as Docker container

You can run this service as Docker container (ghcr.io/graphql-hive/composition-federation-2), from the published Docker image we provide.

To run the service, use the following command:

docker run -p 3069 -e SECRET="MY_SECRET_HERE" ghcr.io/graphql-hive/composition-federation-2

The container runs on port 3069 by default (you can chnage it using PORT env var), and listens to POST /compose requests coming from Hive platform.

You should make this service publicly available and accessible to use it with Hive Cloud platform, or make it availble in your local/private network if you are using Hive on-prem.

Running from source code

You can clone this repository, install dependencies (pnpm install) and then run this service directly, by running:

cd packages/services/external-composition/federation-2
export SECRET="MY_SECRET_HERE"
pnpm dev

Or, to run the built version:

cd packages/services/external-composition/federation-2
pnpm build
export SECRET="MY_SECRET_HERE"
node dist/index.js

Hive Integration

Here you can find instructions on how to integrate your external composition service with Hive.

You'll need to use the public address of your service, and the secret you selected.

The service created here listens to POST /compose requests, so the endpoint you are using should be composed from the public endpoint of this service, and the /compose path.