back to home

wundergraph / graphql-go-tools

GraphQL Router / API Gateway framework written in Golang, focussing on correctness, extensibility, and high-performance. Supports Federation v1 & v2, Subscriptions & more.

817 stars
160 forks
42 issues
GoJavaScriptGo Template

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing wundergraph/graphql-go-tools in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/wundergraph/graphql-go-tools)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

GraphQL Router / API Gateway Framework written in Golang We're hiring! Are you interested in working on graphql-go-tools? We're looking for experienced Go developers and DevOps or Platform Engineering specialists to help us run Cosmo Cloud. If you're more interested in working with Customers on their GraphQL Strategy, we also offer Solution Architect positions. Check out the currently open positions. The State of GraphQL Federation 2024 Get insights from industry experts and Federation practitioners across all industries and learn how companies are using GraphQL Federation. Head over to the State of GraphQL Federation 2024 page and download the full **48 page PDF report** for free! From the WunderGraph Blog Here's a selection of blog posts that focus on the technical aspects of GraphQL Federation, diving into the internals of this library: • **How we scaled Cosmo Router for the SuperBowl** • **The Architecture of our Observability Stack** • **How Normalization affects Query Planning** • **Zero cost abstraction for the @skip and @include Directives** • **Algorithm to minify GraphQL ASTs by up to 99%** • **Federated GraphQL Subscriptions with NATS and Event Driven Architecture** • **Implementing the viewer pattern in GraphQL Federation** • **How we're using Epoll/Kqueue to scale GraphQL Subscriptions** • **ASTJSON - A fast way to merge JSON objects** • **Dataloader 3.0, an efficient algorithm for Federation data loading** Replacement for Apollo Router If you're looking for a complete ready-to-use Open Source Router for Federation, have a look at the Cosmo Router which is based on this library. Cosmo Router wraps this library and provides a complete solution for Federated GraphQL including the following features: • [x] Federation Gateway • [x] OpenTelemetry Metrics & Distributed Tracing • [x] Prometheus Metrics • [x] GraphQL Schema Usage Exporter • [x] Health Checks • [x] GraphQL Playground • [x] Execution Tracing Exporter & UI in the Playground • [x] Federated Subscriptions over WebSockets (graphql-ws & graphql-transport-ws protocol support) and SSE • [x] Authentication using JWKS & JWT • [x] Highly available & scalable using S3 as a backend for the Router Config • [x] Persisted Operations / Trusted Documents • [x] Traffic Shaping (Timeouts, Retries, Header & Body Size Limits, Subgraph Header forwarding) • [x] Custom Modules & Middleware State of the packages This repository contains multiple packages joined via workspace. | Package | Description | Package dependencies | Maintenance state | |---------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------| | graphql-go-tools v2 | GraphQL engine implementation consisting of lexer, parser, ast, ast validation, ast normalization, datasources, query planner and resolver. Supports GraphQL Federation. Has built-in support for batching federation entity calls | - | actual version, active development | | execution | Execution helpers for the request handling and engine configuration builder | depends on graphql-go-tools v2 and composition | actual version | | examples/federation | Example implementation of graphql federation gateway. This example is not production ready. For production ready solution please consider using cosmo router | depends on execution package | actual federation gateway example | | graphql-go-tools v1 | Deprecated and retracted GraphQL engine implementation. Not supported nor maintained. It was removed from the repo in v1.67.5. | - | deprecated | Notes This library is used in production at WunderGraph. We support and actively improve only the v2 module. We have customers who pay us to maintain this library and steer the direction of the project. Contact us if you're looking for commercial support, features or consulting. Performance The architecture of this library is designed for performance, high throughput and low garbage collection overhead. The following benchmark measures the "overhead" of loading and resolving a GraphQL response from four static in-memory Subgraphs at 0,007459 ms/op. In more complete end-to-end benchmarks, we've measured up to 8x more requests per second and 8x lower p99 latency compared to Apollo Router, which is written in Rust. Tutorial If you're here to learn how to use this library to build your own custom GraphQL Router or API Gateway, here's a speed-run tutorial, based on how we use this library in Cosmo Router. query Hello { world } query { hello foo { bar } } { hello foo { bar } } query MyQuery { hello foo { bar } } query MyQuery { hello hello foo { bar bar } ...MyFragment } fragment MyFragment on Query { hello foo { bar } } type Query { hello: String foo: Foo } type Foo { bar: String } schema { query: Query } query MyQuery { helo } type Query { hello: String } `) report := &operationreport.Report{} operationDocumentParser := astparser.NewParser() operationDocument := ast.NewSmallDocument() operationDocument.Input.ResetInputBytes(input) operationDocumentParser.Parse(operationDocument, report) if report.HasErrors() { panic(report.Error()) } schemaParser := astparser.NewParser() schemaDocument := ast.NewSmallDocument() schemaDocument.Input.ResetInputBytes(schema) schemaParser.Parse(schemaDocument, report) if report.HasErrors() { panic(report.Error()) } err := asttransform.MergeDefinitionWithBaseSchema(schemaDocument) if err != nil { panic(err) } validator := astvalidation.DefaultOperationValidator…