quorum/vendor/github.com/graph-gophers/graphql-go
Sai V c215989c10
Quorum geth upgrade to 1.9.7 (#960)
Co-authored-by: amalraj.manigmail.com <amalraj.manigmail.com>
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
Co-authored-by: Flash Sheridan <flash@pobox.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Nguyen Kien Trung <trung.n.k@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Rob Mulholand <rmulholand@8thlight.com>
Co-authored-by: Felföldi Zsolt <zsfelfoldi@gmail.com>
Co-authored-by: soc1c <soc1c@users.noreply.github.com>
Co-authored-by: Rafael Matias <rafael@skyle.net>
Co-authored-by: gary rong <garyrong0905@gmail.com>
Co-authored-by: Lucas Hendren <lhendre2@gmail.com>
Co-authored-by: Ryan Schneider <ryanleeschneider@gmail.com>
Co-authored-by: ywzqwwt <39263032+ywzqwwt@users.noreply.github.com>
Co-authored-by: zcheng9 <zcheng9@hawk.iit.edu>
Co-authored-by: zzy96 <zhou0250@e.ntu.edu.sg>
Co-authored-by: kikilass <36239971+kikilass@users.noreply.github.com>
Co-authored-by: Darrel Herbst <dherbst@gmail.com>
Co-authored-by: Ross <9055337+Chadsr@users.noreply.github.com>
Co-authored-by: Jeffery Robert Walsh <rlxrlps@gmail.com>
Co-authored-by: Marius Kjærstad <sandakersmann@users.noreply.github.com>
Co-authored-by: Piotr Dyraga <piotr.dyraga@keep.network>
Co-authored-by: Guillaume Ballet <gballet@gmail.com>
Co-authored-by: Michael Forney <mforney@mforney.org>
Co-authored-by: Samuel Marks <807580+SamuelMarks@users.noreply.github.com>
2020-04-29 10:50:56 -04:00
..
errors Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
internal Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
introspection Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
log Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
relay Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
trace Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
Gopkg.lock Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
Gopkg.toml Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
LICENSE Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
README.md Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
graphql.go Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
id.go Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
introspection.go Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
time.go Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00

README.md

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

Basic Sample

package main

import (
        "log"
        "net/http"

        graphql "github.com/graph-gophers/graphql-go"
        "github.com/graph-gophers/graphql-go/relay"
)

type query struct{}

func (_ *query) Hello() string { return "Hello, world!" }

func main() {
        s := `
                schema {
                        query: Query
                }
                type Query {
                        hello: String!
                }
        `
        schema := graphql.MustParseSchema(s, &query{})
        http.Handle("/query", &relay.Handler{Schema: schema})
        log.Fatal(http.ListenAndServe(":8080", nil))
}

To test:

$ curl -XPOST -d '{"query": "{ hello }"}' localhost:8080/query

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 authentication