Documentation
Documentation
github.com/gql-go/graphql is a code-first implementation of GraphQL in Go: the
schema is defined in Go code, and queries, mutations and subscriptions run
against it. It follows the GraphQL specification
and uses graphql-js as the reference
for behaviour.
It is the community-maintained continuation of
graphql-go/graphql. Code written
against graphql-go/graphql v0.8.1 keeps compiling and behaving the same way;
new behaviour is enabled through configuration.
Start here
Install the library, define a first schema and run a query against it.
Move from graphql-go/graphql: the steps, what stays the same and the few changes that may need action.
The schema as Go code: composed with functions, built at runtime, tested without a server, and no generate step.
Schema
Object types, fields, arguments, lists and non-null, and types that refer to each other.
Abstract types, ResolveType and IsTypeOf, and querying them with fragments.
Named values mapped to Go values, in fields and arguments.
Structured arguments for mutations, from literals and variables.
Leaf types with your own conversion to and from Go.
Built-in and custom directives in queries.
Values of your own attached to schema elements.
Resolvers
ResolveParams and ResolveInfo, return values, errors and panics, and testing resolvers.
How fields without a resolver read structs, maps and FieldResolver values.
Request values, per-request caches, deadlines and cancellation.
Running slow work in parallel by returning a function.
Execution
Running requests, operations, variables, the result, and prepared documents.
Field errors, error codes, and masking internal errors.
Reporting and rejecting values that cannot be serialized.
Tracing, metrics and logging with hooks on every request and field.
Other topics
Subscription fields, running them with Subscribe, producing events, and ending them cleanly.
The specified rules, validating documents yourself, and writing and adding rules such as a depth limit.
Skipping parsing and validation for repeated queries with PlanCache, normalization, and plans you keep.
Parsing documents, the syntax tree, printing, and walking and rewriting it with the visitor.
HTTP
Where to find what
These guides explain how to use the library. The details of each type and function are in the API reference.
Every type and function, with runnable examples, on pkg.go.dev.
Complete programs: CRUD, context, concurrent resolvers, custom scalars, HTTP servers.
What is planned next, with an issue for each item.
The changes in each version and who made them.
Versions
The guides describe the latest release. A feature added after v0.9.0 is
marked with the version that introduced it.
Getting help
- Questions and ideas: GitHub Discussions.
- Bugs and differences from the specification: open an issue.
- Security problems: follow the security policy instead of opening a public issue.
- Something wrong or missing in these pages: use “Edit this page on GitHub” on any page, or open an issue.
Last updated on