Documentation
Gateway
Getting Started

Hive Gateway

Hive Gateway is a fully open-source MIT-licensed GraphQL gateway that can act as a Apollo Federation Gateway or a Proxy Gateway for any GraphQL services.

The Hive Gateway can be run as a standalone binary, a Docker Image, or as a JavaScript package (e.g. within Node.js, Bun, Deno, Google Cloud Functions, Azure Functions or Cloudflare Workers)

Hive Gateway provides the following features on top of your Federated GraphQL schema or proxied 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 Apollo 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 CLI Reference.

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',
    endpoint:
      'http://cdn.graphql-hive.com/artifacts/v1/12713322-4f6a-459b-9d7c-8aa3cf039c2e/supergraph',
    key: 'YOUR HIVE CDN KEY'
  }
})

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.