Apollo Federation 2
If you wish to run Apollo Federation 2 with the self-hosted version of Hive, please starting by reading about the limitations of using Apollo Federation 2 with Hive.
The process of running the self-host version with Apollo Federation 2 is similar to the process of running it with Hive Cloud version - you'll need to run the external composition service. The difference is that you'll be able to run it locally, instead of running it on a publicly available service.
We provide a Docker image (opens in a new tab) for running external composition service for Apollo Federation v2.
The pre-built image implements the best-practice to secure your endpoint, and uses the latest version of Apollo Federation v2.
For self-hosting we recommend adding the external composition federation container configuration to
your docker-compose.community.yml
:
services:
# ... other services
composition-federation-2:
image: '${DOCKER_REGISTRY}composition-federation-2${DOCKER_TAG}'
networks:
- 'stack'
healthcheck:
test: ['CMD', 'wget', '--spider', '-q', 'localhost:3069/_readiness']
interval: 5s
timeout: 5s
retries: 6
start_period: 5s
ports:
- 3069:3069
environment:
PORT: 3069
SECRET: '${EXTERNAL_COMPOSITION_SECRET}'
Make sure to set the EXTERNAL_COMPOSITION_SECRET
environment variable to a secure value.
export EXTERNAL_COMPOSITION_SECRET=$(openssl rand -hex 16)
After that and restarting your stack, you can use the external composition service by adding it to an existing project in the Settings.
Since the Hive server is using the internal docker network, you need to use the service name as the
hostname http://composition-federation-2:3069/compose
. Also, make sure to use the correct secret.