Skip to content

gqlgen vs graphql-go

Which should you use? A side-by-side look at what each one does, who it suits, what it costs, how hard it is to set up, and where each falls short.

gqlgen

Open source · MIT

A Go library that generates GraphQL server code from a schema you write.

graphql-go

Open source · MIT

A Go library for building GraphQL servers, following the reference graphql-js implementation.

The short answer

Choose gqlgen if you need…

  • Go developers building a new GraphQL API
  • Teams that prefer defining the schema first and generating code from it
  • Projects that need typed models instead of map[string]interface{}
  • Developers who want to control which nested fields are fetched, using custom models or explicit resolvers

Choose graphql-go if you need…

  • Go developers who want to expose a GraphQL API from a Go service
  • Teams that want to build a schema in Go code rather than a separate schema file
  • Developers who want to match graphql-js behavior in a Go backend

Side-by-side

gqlgengraphql-go
TypeLibraryLibrary
PriceFree and open sourceFree and open source
LicenceMITMIT
GitHub stars10.8k10.1k
Setup difficultyIntermediateIntermediate
How you get itInstall with a package managerInstall with a package manager
Main languageGoGo
Last code update8 days ago5 months ago

What each one is

gqlgen

gqlgen is a Go library for building GraphQL servers. You describe your API in the GraphQL Schema Definition Language, and gqlgen generates the Go code for the types and resolver functions, so you mainly write the logic that fetches the data. It is aimed at Go developers who want type-safe code rather than loosely typed maps.

graphql-go

This is a Go library that lets you define a GraphQL schema and run GraphQL queries against it from Go code. GraphQL is a way for clients to ask an API for exactly the fields they need. The README says it follows the official graphql-js reference implementation and supports queries, mutations and subscriptions.

Best for

gqlgen

  • Go developers building a new GraphQL API
  • Teams that prefer defining the schema first and generating code from it
  • Projects that need typed models instead of map[string]interface{}
  • Developers who want to control which nested fields are fetched, using custom models or explicit resolvers

graphql-go

  • Go developers who want to expose a GraphQL API from a Go service
  • Teams that want to build a schema in Go code rather than a separate schema file
  • Developers who want to match graphql-js behavior in a Go backend

Strengths

gqlgen

  • Schema-first workflow: the GraphQL schema is the source of truth and Go code is generated from it
  • Generated code is typed, which the README emphasizes as avoiding loosely typed maps
  • Documented getting-started tutorial, reference docs, and example projects

graphql-go

  • Follows the official graphql-js reference implementation, according to the README
  • Covers queries, mutations and subscriptions
  • Has godoc documentation and a small runnable example in the README

Not ideal for

gqlgen

  • Developers not using Go, since the library is written for Go and the README shows only Go code
  • Projects that need a GraphQL server in another language
  • Anyone who wants a fully finished application out of the box, since gqlgen generates a server skeleton you still have to fill in

graphql-go

  • People who are not writing Go, since this is a Go library and needs a Go toolchain
  • Anyone looking for a ready-made server or hosted app, since the README describes a library, not a finished product
  • Projects that need the README's documented feature set beyond queries, mutations and subscriptions, because the README does not list more detail

Trade-offs

gqlgen

  • You must learn both GraphQL schema concepts and gqlgen's configuration (gqlgen.yml or directives) to customize behavior
  • The README notes some interface getters can't cover every case, such as Relay-style connections, so you may need the omit_getters option
  • The README is truncated here, so details of subscriptions and dataloader support are not confirmed from the text provided

graphql-go

  • The README is truncated and gives only a single small example, so advanced usage relies on the examples directory and tests
  • The latest release is v0.8.1 and has no binaries, since it is a library rather than a program
  • HTTP serving is not included; the README points to a separate third-party handler

Getting started

gqlgen

Create a new Go module

mkdir example && cd example && go mod init example

Add gqlgen as a tool dependency

go get -tool github.com/99designs/gqlgen
Step-by-step guide: how to use gqlgen

graphql-go

Install the library

go get github.com/graphql-go/graphql
Step-by-step guide: how to use graphql-go

Frequently asked questions

What is the difference between gqlgen and graphql-go?

gqlgen: A Go library that generates GraphQL server code from a schema you write. graphql-go: A Go library for building GraphQL servers, following the reference graphql-js implementation. gqlgen suits go developers building a new graphql api, while graphql-go suits go developers who want to expose a graphql api from a go service.

Are gqlgen and graphql-go free?

gqlgen: Free and open source. graphql-go: Free and open source.

Is gqlgen or graphql-go more popular?

gqlgen has more GitHub stars (10.8k) than graphql-go (10.1k). Popularity isn't the same as fit — check which one matches your use case above.

What are other alternatives to gqlgen and graphql-go?

Other options people compare them with include DataLoader.

Keep comparing

Built from our catalogue entries for both products: open-source details come from each project's README (AI-assisted, refreshed weekly) and GitHub data; AI-tool details are editorial. Spotted something wrong? Let us know from either product's page.