graphql
An implementation of GraphQL for Go / Golang
A Go library for building GraphQL APIs where you define your data schema and resolvers and the library handles parsing, validation, and execution of client queries, mutations, and subscriptions.
This is a Go library that lets you build GraphQL APIs. GraphQL is a way of querying data from a server where the client specifies exactly what fields it wants, rather than receiving a fixed response structure. Instead of calling separate endpoints for different data, you send a single query describing the shape of data you need, and the server returns only that.
This library provides the underlying machinery for Go applications to define a GraphQL schema and handle incoming queries against it. You describe your data types and how each field gets its value, then the library parses and runs queries from clients. It supports the three main operation types in GraphQL: queries for reading data, mutations for changing data, and subscriptions for receiving updates over time.
The implementation follows the official JavaScript reference library closely, so behavior should match what GraphQL clients expect. To add it to a Go project, you run a single install command. The repository includes a companion package for handling GraphQL over HTTP, which is the common way to expose a GraphQL API to web clients. There is also a package for working with Relay, a popular client-side data management system used with React.
The README is short and the project is focused narrowly on one thing. If you are building a Go backend and want to offer a GraphQL interface to your data, this library handles parsing, validation, and execution. You provide the schema definition and the logic that fetches each piece of data; the library handles the rest.
Where it fits
- Add a GraphQL API to a Go backend so clients can request exactly the fields they need in a single query instead of multiple REST calls.
- Build a Go server that handles GraphQL queries, mutations, and real-time subscriptions for a web or mobile app.
- Use the companion HTTP handler package to expose your Go GraphQL schema over a standard web endpoint.