GraphQL Gateway
Hive Gateway is an open-source, MIT-licensed GraphQL gateway: a Federation router or a proxy for any GraphQL API, with auth, caching and OpenTelemetry built in.
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 Gateway and Apollo Router, Hive Gateway provides a flexible, open-source solution tailored to meet the needs of modern GraphQL architectures. It serves Apollo Federation v1 and v2 supergraphs.
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.
What is a GraphQL gateway?
A GraphQL gateway is the single endpoint your clients send GraphQL operations to, in front of the services that hold the data. For each operation it validates the request, plans which service resolves which field, calls those services (in parallel where it can) and merges their results into one response. Because every request passes through it, the gateway is also where authentication, authorization, rate limiting, caching and observability live.
With GraphQL Federation, those services are subgraphs, and the gateway reads a supergraph schema that says which subgraph resolves which field. A gateway can also sit in front of a single, non-federated GraphQL API as a proxy, to add the same features without changing the API itself.
GraphQL router or GraphQL gateway?
The two names describe the same role. “Router” became common when Apollo called its Rust runtime Apollo Router and its JavaScript one Apollo Gateway. Hive follows the same split: Hive Router is written in Rust and Hive Gateway in TypeScript, and both serve Federation v1 and v2 supergraphs. See Hive Router or Hive Gateway to choose between them.
Features
Our GraphQL API Gateway provides the following features on top of your GraphQL schema:
- GraphQL Subscriptions with WebSockets, HTTP Callbacks or SSE, and Event-Driven Federated Subscriptions through a message broker
- Incremental Delivery with
@deferand@stream - An optional Rust Query Planner, the planner of Hive Router as a native addon
- An MCP Server (beta) that exposes selected GraphQL operations to AI agents as tools
- Automatic query and request batching to reduce the number of HTTP requests to your subgraph
- JSON Web Tokens (JWT) authentication between client and gateway also between gateway and subgraph
- Authorization on specific fields and types using
Federation Auth directives like
@authenticatedand@skipAuth - Role-based Access Control (RBAC) either
programmatically or with directives
@requiresScopeand@policy - Response Caching based on either in
memory or Redis for distributed caching optionally with
@cacheControldirective - Security features such as safelisting, depth limit etc
- Demand Control with
@costand@listSize - Progressive Override to move fields between subgraphs gradually
- Upstream reliability with retries and timeouts per subgraph
- Rate Limiting on specific fields and types
either programmatically or declaratively with
@rateLimitdirective - Prometheus and OpenTelemetry integration with fully customizable spans and attributes
- Persisted Documents backed by either Hive Registry or a selfhosting storage
- E2E HTTP Compression from the client to the subgraph for better performance and resource management
- And more
Installation
Hive Gateway can be installed in different ways depending on your preference.
This command will download the appropriate binary for your operating system.
To install a specific Hive Gateway version, pass a valid release version (for example X.Y.Z) to the script:
You can use the official Docker image to run Hive Gateway.
To use the NPM package, you need to have Node.js 22.15 or later installed in your environment. Then, you can install Hive Gateway CLI with your preferred package manager.
Starting the Gateway
Hive Gateway supports two different modes:
- GraphQL Federation. Serve a supergraph provided by a schema registry like Hive Registry, a composition tool like Apollo Rover, GraphQL Mesh or any other Federation compliant composition tool such as Apollo Rover or schema registry (Hive Registry, Apollo GraphOS)
- Proxy a GraphQL API. Hive Gateway can also act as a proxy to an existing GraphQL API.
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.
If you installed the JavaScript package, you can use npx for running the CLI.
In order to proxy a GraphQL API, we need to provide the URL of the API when starting our Gateway. Optionally, we can also provide a schema file from either a local file or a schema registry, which will be used instead of instrospecting the proxied API.
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.
Hive Gateway will automatically load the default config file and apply the settings.
For docker, we need to mount the configuration file into the container.
Hive Gateway will automatically load the default config file and apply the settings.
For docker, we need to mount the configuration file into the container.
Next steps
After learning the first steps of Hive Gateway, you can explore the following topics.