
graphql-go
A Go library for building GraphQL servers, following the reference graphql-js implementation.graphql-go/graphql
- Stars
- 10.1k
- Forks
- 850
- Licence
- MIT
- Language
- Go
- Last update
- 5 months ago
- Type
- Library
What it is
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.
- Define a schema with object types and fields in Go and resolve them with Go functions
- Run a GraphQL query string against a schema and get JSON results back
- Add mutations and subscriptions to a Go API
- Pair it with the third-party graphql-go-handler listed in the README to serve queries over HTTP
Great for
- 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
Not ideal for
- 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
How to get it
- 1
Install with a package manager
You'll need: Go
Install the library
go get github.com/graphql-go/graphql - 2
Run it
- Install the library with go get
- Copy the hello-world example from the README into a main.go file
- Run the program with go run main.go
- Check that it prints {"data":{"hello":"world"}}
- 3
Get the most out of it
- Read the examples/ directory in the repository for more complex schemas
- Review graphql_test.go to see how features are exercised
- Use the godoc reference at pkg.go.dev for the full API
- Add graphql-go-handler to serve your schema over HTTP
- Consider dataloader from the README to batch data fetches
Downloads
Strengths
- 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
Trade-offs
- 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
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| graphql (this) | 10.1k | Library | intermediate | 5 months ago | Go developers who want to expose a GraphQL API from a Go service |
| gqlgen | 10.8k | Library | intermediate | 8 days ago | Go developers building a new GraphQL API |
| apollo-server | 14k | Library | intermediate | 5 days ago | Node.js developers who want to add a GraphQL API to an existing Express, Koa or Hapi app |
| hoppscotch | 80.7k | App | beginner | 6 days ago | Developers who want to test REST, GraphQL, WebSocket, or other APIs without a heavy desktop client |
| query | 50.5k | Library | intermediate | 4 days ago | Frontend developers building apps that load data from a server |
| graphql-js | 20.3k | Library | intermediate | 4 days ago | JavaScript or TypeScript developers building a GraphQL API on Node.js |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.