How graphql-hive/gateway works
Project Type and Purpose
• This is an open-source GraphQL API Gateway (“Hive Gateway”) monorepo.
• Key deliverables: a CLI/binary entrypoint, a configurable GraphQL server runtime, pluginable execution pipeline, and support for multiple deployment targets (Node, Bun, Docker, Cloud Functions, Workers).
Top-Level Architectural Components
• CLI / Binary Launcher (packages/gateway/src/bin.ts & cli.ts)
• Gateway Server & Configuration Loader (packages/gateway/src/index.ts, config.ts)
• Runtime Core (packages/runtime & packages/fusion-runtime)
• Plugin System (packages/runtime/src/plugins + packages/plugins/*)
• Request Execution Pipeline
– Parsing & Validation (built-in GraphQL library)
– Delegation/Planning (packages/delegate, batch-delegate, stitch)
– Batching & Execution (packages/batch-execute, executors/http, executors/graphql-ws)
• Transport & Executors (HTTP, WebSocket, GraphQL-WS)
• Deployment Targets (Docker images, Node/Bun runtime, Cloudflare Workers)
Relationships & Data Flow
1. Client → HTTP / WebSocket / GraphQL-WS → CLI/Server entrypoint
2. Configuration Loader reads supergraph definition or proxy config.
3. Fusion-Runtime / UnifiedGraphManager builds in-memory schema graph.
4. Incoming GraphQL operation flows through the plugin stack (e.g. auth, metrics, caching).
5. Planner (delegate/stitch) splits the operation into subrequests.
7. Responses aggregated, merged, returned to client.
Architectural Patterns & Principles
• Modular monorepo: each package is a composable building block (batch delegate, delegate, stitch, wrap, federation, gateway, runtime).
• Plugin pipeline: hooks at critical phases (pre-parse, pre-execute, post-execute).
• Strategy / Factory patterns for executors & transports.
• Separation of concerns: configuration, planning, execution, transport are distinct modules.
Technologies & Frameworks
• Node.js & Bun support via rollup & custom binaries (packages/gateway).
• Yarn 2 workspaces, TypeScript.
• GraphQL core.
• Docker / Docker-Bake (docker-bake.hcl) for containerized deployment.
• CI/CD workflows (.github/workflows).