Repolode
99designs

99designs/gqlgen

A Go library that generates type-safe GraphQL server code from a schema-first GraphQL definition.

Stars
10,767
Forks
1,262
Open issues
396
Last commit
14 hours ago

What is it?

gqlgen is a Go library for building GraphQL servers. You define the API in GraphQL Schema Definition Language, and gqlgen generates the Go types and resolver interfaces you need, so you write the business logic while the boilerplate is produced for you. The generated code is typed throughout rather than relying on map[string]interface{}.

The project runs through the go generate workflow and is integrated with the Go toolchain via tool dependencies. Configuration is done in a gqlgen.yml file, where you can map GraphQL types to existing Go structs, force resolvers for specific fields, and change how IDs are represented, for example as int or string. Field resolvers can be executed concurrently, with the degree of concurrency controlled by a worker_limit setting.

The repository also includes a feature comparison page against other Go GraphQL implementations, along with a getting started tutorial, reference docs on pkg.go.dev, and example applications.

Key features

  • 01Schema-first development: define the API in GraphQL SDL and generate code from it.
  • 02Generates typed Go models and resolver interfaces, avoiding untyped maps.
  • 03Maps GraphQL types to existing Go structs via gqlgen.yml or directives.
  • 04Supports forcing resolvers on specific fields to avoid fetching unused child data.
  • 05Configurable ID type mapping between int, uint and string.
  • 06Concurrent field resolver execution with a configurable worker limit.

Use cases

  • Building a GraphQL API backend in Go where type safety is a priority.
  • Adding a GraphQL layer on top of existing Go structs and data models.
  • Teams that prefer designing the API schema first and generating server code from it.

Quick start

  1. 1

    Create and enter a new Go module directory

    mkdir example cd example go mod init example
  2. 2

    Add gqlgen as a tool dependency

    go get -tool github.com/99designs/gqlgen
  3. 3

    Initialise gqlgen config and generate models

    go tool gqlgen init
  4. 4

    Start the GraphQL server

    go run server.go

Things to know

  • Requires Go to be installed and is a library for Go servers only.
  • Schema-first design means you must write the GraphQL schema and resolvers yourself.

Topics

FAQ

What is gqlgen?
A Go library that generates type-safe GraphQL server code from a schema-first GraphQL definition. gqlgen is a Go library for building GraphQL servers. You define the API in GraphQL Schema Definition Language, and gqlgen generates the Go types and resolver interfaces you need, so you write the business logic while the boilerplate is produced for you. The generated code is typed throughout rather than relying on map[string]interface{}.
Is gqlgen free to use? What license does it have?
gqlgen is open source under the MIT license. Check the license terms before using it in commercial products.
Is gqlgen still maintained?
Actively maintained. The last commit to gqlgen was on Oct 21, 2026.
What can I use gqlgen for?
Building a GraphQL API backend in Go where type safety is a priority. Adding a GraphQL layer on top of existing Go structs and data models. Teams that prefer designing the API schema first and generating server code from it.
How do I install gqlgen?
Create and enter a new Go module directory: mkdir example cd example go mod init example Add gqlgen as a tool dependency: go get -tool github.com/99designs/gqlgen Initialise gqlgen config and generate models: go tool gqlgen init Start the GraphQL server: go run server.go
Where can I get gqlgen?
The source code and installation instructions are on GitHub: https://github.com/99designs/gqlgen

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects