DocumentationGatewayGetting Started

Hive Gateway

Hive Gateway is a fully open-source, MIT-licensed GraphQL router that can act as a GraphQL Federation gateway, a subgraph or a proxy gateway for any GraphQL API service.

As an alternative to Apollo Router, Hive Gateway provides a flexible, open-source solution tailored to meet the needs of modern GraphQL architectures.

It supports deployment as a standalone binary, a Docker image, or a JavaScript package, making it compatible with environments such as Node.js, Bun, Deno, Google Cloud Functions, Azure Functions, or Cloudflare Workers.

Our GraphQL API Gateway provides the following features on top of your GraphQL schema:

Installation

Hive Gateway can be installed in different ways depending on your preference.

This command will download the appropriate binary for your operating system.

curl -sSL https://graphql-hive.com/install-gateway.sh | sh

Starting the Gateway

Hive Gateway supports two different modes:

To serve a GraphQL federation Gateway, we need to point the Gateway to either a local supergraph file or a supergraph served by our schema registry. For this example, we will serve a supergraph from the Hive schema registry.

Run Apollo Federation Gateway with the Hive Gateway Binary
hive-gateway supergraph \
  http://cdn.graphql-hive.com/artifacts/v1/12713322-4f6a-459b-9d7c-8aa3cf039c2e/supergraph \
  --hive-cdn-key "YOUR HIVE CDN KEY"

By default, Hive Gateway will start a server on port 4000. You can customize that behavior. For that please refer to our Gateway documentation.

Configuration File

The Hive Gateway config file gateway.config.ts is used for enabling additional features such as authorization, authentication caching, rate limiting, and more. The recommended language for the configuration file is TypeScript.

We can provide the CLI configuration parameters, also via the configuration file.

gateway.config.ts
import { defineConfig } from '@graphql-hive/gateway'
 
export const gatewayConfig = defineConfig({
  supergraph: {
    type: 'hive',
    // The endpoint of Hive's CDN
    endpoint: '<supergraph endpoint>',
    // The CDN token provided by Hive Registry
    key: '<cdn access token>'
  }
})

Hive Gateway will automatically load the default config file and apply the settings.

Run Proxy Gateway with the Hive Gateway Binary using configuration file
hive-gateway supergraph

Next steps

After learning the first steps of Hive Gateway, you can explore the following topics.