API Reference

gqlgen

A Go GraphQL server library generated from a schema, providing type-safe resolvers and code generation.

Official Documentation ↗
CompatibilityThis documentation covers version v0.17. Check the official docs for the latest API surface.

Installation

gogo get github.com/99designs/gqlgen

Methods

gqlgen compiles a GraphQL schema into Go interfaces and wires resolvers to an http handler.

Key Features

  • Schema-first code generation
  • Type-safe resolver interfaces
  • Data loaders for batching and caching

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

FAQ

Do I write the schema or the code first?
Schema first. You define types and queries in .graphql, run gqlgen generate, and fill in the generated resolver methods.
How do I avoid the N+1 problem?
Use dataloaden or gqlgen dataloaders to batch field resolution across a single request instead of resolving per object.
Can I limit query depth?
Yes. Add a complexity or depth extension to the handler so malicious deeply nested queries are rejected.