Categorygithub.com/oraiapp/graphql-go
modulepackage
0.0.0-20180411221916-9ebf33af539a
Repository: https://github.com/oraiapp/graphql-go.git
Documentation: pkg.go.dev

# README

graphql-go Sourcegraph Build Status GoDoc

The goal of this project is to provide full support of the GraphQL draft specification with a set of idiomatic, easy to use Go packages.

While still under heavy development (internal APIs are almost certainly subject to change), this library is safe for production use.

Features

  • minimal API
  • support for context.Context
  • support for the OpenTracing standard
  • schema type-checking against resolvers
  • resolvers are matched to the schema based on method sets (can resolve a GraphQL schema with a Go interface or Go struct).
  • handles panics in resolvers
  • parallel execution of resolvers

Roadmap

We're trying out the GitHub Project feature to manage graphql-go's development roadmap. Feedback is welcome and appreciated.

(Some) Documentation

Resolvers

A resolver must have one method for each field of the GraphQL type it resolves. The method name has to be exported and match the field's name in a non-case-sensitive way.

The method has up to two arguments:

  • Optional context.Context argument.
  • Mandatory *struct { ... } argument if the corresponding GraphQL field has arguments. The names of the struct fields have to be exported and have to match the names of the GraphQL arguments in a non-case-sensitive way.

The method has up to two results:

  • The GraphQL field's value as determined by the resolver.
  • Optional error result.

Example for a simple resolver method:

func (r *helloWorldResolver) Hello() string {
	return "Hello world!"
}

The following signature is also allowed:

func (r *helloWorldResolver) Hello(ctx context.Context) (string, error) {
	return "Hello world!", nil
}

Community Examples

tonyghita/graphql-go-example - A more "productionized" version of the Star Wars API example given in this repository.

deltaskelta/graphql-go-pets-example - graphql-go resolving against a sqlite database

OscarYuen/go-graphql-starter - a starter application integrated with dataloader, psql and basic authenication

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

Logger is used to log panics durring query execution.
MaxDepth specifies the maximum field nesting depth in a query.
MaxParallelism specifies the maximum number of resolvers per request allowed to run in parallel.
MustParseSchema calls ParseSchema and panics on error.
ParseSchema parses a GraphQL schema and attaches the given root resolver.
Tracer is used to trace queries and fields.
ValidationTracer is used to trace validation errors.

# Structs

Response represents a typical response of a GraphQL server.
Schema represents a GraphQL schema with an optional resolver.
Time is a custom GraphQL type to represent an instant in time.

# Type aliases

ID represents GraphQL's "ID" scalar type.
SchemaOpt is an option to pass to ParseSchema or MustParseSchema.