grx

What grx is

grx in plain language - a Go GraphQL server built from structs, with HTTP, realtime transports, hooks, and production controls.

grx is a GraphQL server and runtime for Go. You describe your API in code: exported structs and methods become GraphQL types, fields, and resolvers (schema.Config feeding grx.WithSchema). The library turns that bundle into an executable schema, runs query, mutation, and optional subscription operations, and returns spec-shaped JSON - all behind a normal net/http.Handler so Chi, Gin, Echo, Fiber, ServeMux, or bare ListenAndServe can host it equally.

Dependencies

Runtime dependencies are deliberately small (see go.mod in the repo). You integrate databases, caches, Auth0, OTLP exporters, etc. - grx wires the GraphQL mechanics and transports.


Who it is for

  • Teams shipping production GraphQL backends in Go who want reflection-driven schema authoring instead of parallel SDL/codegen upkeep.
  • Services that sometimes need realtime pushes (WebSocket, SSE, optional pub/sub) without swapping frameworks.
  • Engineers who prefer readable extension points: plugins, authorizers, and custom transports - not a sprawling plugin ecosystem.

What you get (feature surface)

These are concrete capabilities surfaced by the codebase and documented here - not marketing bullets.

Schema and execution

CapabilityMeaning
Code-first schemaStructs + gql struct tags model object types, arguments, descriptions, deprecation - Define your schema.
RootsRequired Query, optional Mutation and Subscription via schema.Config.
ExecutorLex, parse, validate, and execute GraphQL documents with behavior documented in the relevant execution guides.
Structured errorsField errors with path and locations; masking for clients via Security.

Networking and ergonomics

CapabilityMeaning
GraphQL over HTTPDefault handler accepts JSON bodies on your configured path - Transports.
Optional GraphiQLWithPlaygroundPath serves the bundled sandbox for dev - turn it off in production (Introspection).
Router-neutralEverything is http.Handler - mount anywhere (Get started).
CORS wiringConfigure CORS in the host HTTP server or framework around the returned http.Handler.
Gzip responsesOptional WithResponseGzip for JSON payloads.

Realtime graph

CapabilityMeaning
Subscription resolversGo methods returning <-chan YourType; runtime streams payloads per event.
WebSocket + SSE transportsFirst-class subscriptions doc + optional Memory backend (Redis adapter for multi-node fan-out cases).

Safety and operations

CapabilityMeaning
Toggle introspectionWithDisableIntrospection rejects __schema / __type.
Request boundsTimeouts (WithRequestTimeout), MaxHTTPRequestBytes, variable caps, selection/alias/root limits - Limits.
APQ / trust listsWithPersistedQueries, TrustedDocuments, RequirePersistedQuery (server.Config) patterns.
Auth hooksOperation + field-level authorizers and HTTP middleware layering - Authentication & authorization.

Observability & extension

CapabilityMeaning
Lifecycle pluginsParse / validation / resolve hooks (plugins package, concepts).
Custom transportsAdd protocols beside the default HTTP pipeline - guide.

How it differs from hand-rolling GraphQL.js-style stacks

Conceptually identical moving parts (schema + resolvers + transport) - grx concentrates them in Go types and one handler tree rather than layering Node + SDL + codegen. Use it when idiomatic structs, low ceremony, and net/http integration outweigh a JavaScript-heavy toolchain.


Next steps

  1. Run your first server (go.mod, graph package, grx.NewServer).
  2. Define your schema in Go for tagging and composition patterns.
  3. Bookmark Security, Introspection, Limits (or Production hardening) before shipping beyond localhost.

Numbers versus other servers: Benchmarks. Package-level API browsing: Reference.

Edit this page on GitHub

Last updated on

On this page