ipld-eth-server/vendor/github.com/neelance/graphql-go
Matt K 605b0a96ae Add graphql server (#27)
* Add graphql server

* Update Makefile

* Update log_filters constraint

* Add GetLogFilter to repo

* Update travis (use Makefile, go fmt, go vet)

* Add logFilter schema and resolvers

* Add GetWatchedEvent to watched_events_repo

* Add watchedEventLog schema and resolvers
2018-02-08 10:12:08 -06:00
..
errors Add graphql server (#27) 2018-02-08 10:12:08 -06:00
example/starwars Add graphql server (#27) 2018-02-08 10:12:08 -06:00
gqltesting Add graphql server (#27) 2018-02-08 10:12:08 -06:00
internal Add graphql server (#27) 2018-02-08 10:12:08 -06:00
introspection Add graphql server (#27) 2018-02-08 10:12:08 -06:00
log Add graphql server (#27) 2018-02-08 10:12:08 -06:00
relay Add graphql server (#27) 2018-02-08 10:12:08 -06:00
trace Add graphql server (#27) 2018-02-08 10:12:08 -06:00
.gitignore Add graphql server (#27) 2018-02-08 10:12:08 -06:00
graphql_test.go Add graphql server (#27) 2018-02-08 10:12:08 -06:00
graphql.go Add graphql server (#27) 2018-02-08 10:12:08 -06:00
id.go Add graphql server (#27) 2018-02-08 10:12:08 -06:00
introspection.go Add graphql server (#27) 2018-02-08 10:12:08 -06:00
LICENSE Add graphql server (#27) 2018-02-08 10:12:08 -06:00
README.md Add graphql server (#27) 2018-02-08 10:12:08 -06:00
time.go Add graphql server (#27) 2018-02-08 10:12:08 -06:00

graphql-go

Sourcegraph Build Status GoDoc

Status

The project is under heavy development. It is stable enough so we use it in production at Sourcegraph, but expect changes.

Goals

  • full support of GraphQL spec (October 2016)
    • propagation of null on resolver errors
    • everything else
  • minimal API
  • support for context.Context and OpenTracing
  • early error detection at application startup by type-checking if the given resolver matches the schema
  • resolvers are purely based on method sets (e.g. it's up to you if you want to resolve a GraphQL interface with a Go interface or a Go struct)
  • nice error messages (no internal panics, even with an invalid schema or resolver; please file a bug if you see an internal panic)
    • nice errors on resolver validation
    • nice errors on all invalid schemas
    • nice errors on all invalid queries
  • panic handling (a panic in a resolver should not take down the whole app)
  • parallel execution of resolvers

(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
}