diff --git a/README.md b/README.md index eead9b08ccb..eb3989f8bbb 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,5 @@ # graphql-go -[![Sourcegraph](https://sourcegraph.com/github.com/neelance/graphql-go/-/badge.svg)](https://sourcegraph.com/github.com/neelance/graphql-go?badge) -[![Build Status](https://semaphoreci.com/api/v1/neelance/graphql-go/branches/master/badge.svg)](https://semaphoreci.com/neelance/graphql-go) -[![GoDoc](https://godoc.org/github.com/neelance/graphql-go?status.svg)](https://godoc.org/github.com/neelance/graphql-go) +The two main existing (github.com/neelance/graphql-go, github/com/graphql-go/graphql) graphql libraries are both very weaky typed and verbose. -## Status - -The project is under heavy development. It is stable enough so we use it in production at [Sourcegraph](https://sourcegraph.com), but expect changes. - -## Goals - -* [ ] full support of [GraphQL spec (October 2016)](https://facebook.github.io/graphql/) - * [ ] propagation of `null` on resolver errors - * [x] everything else -* [x] minimal API -* [x] support for context.Context and OpenTracing -* [x] early error detection at application startup by type-checking if the given resolver matches the schema -* [x] 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) - * [x] nice errors on resolver validation - * [ ] nice errors on all invalid schemas - * [ ] nice errors on all invalid queries -* [x] panic handling (a panic in a resolver should not take down the whole app) -* [x] 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](https://golang.org/ref/spec#Exported_identifiers) 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](https://golang.org/ref/spec#Exported_identifiers) 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: - -```go -func (r *helloWorldResolver) Hello() string { - return "Hello world!" -} -``` - -The following signature is also allowed: - -```go -func (r *helloWorldResolver) Hello(ctx context.Context) (string, error) { - return "Hello world!", nil -} -``` +This is an experiment to use go generate to create a server quickly and with type safety based on the neelance codebase. diff --git a/example/starwars/server/server.go b/example/starwars/server/server.go index ce1a30fe0c8..446ff3f139f 100644 --- a/example/starwars/server/server.go +++ b/example/starwars/server/server.go @@ -4,9 +4,9 @@ import ( "log" "net/http" - "github.com/neelance/graphql-go" - "github.com/neelance/graphql-go/example/starwars" - "github.com/neelance/graphql-go/relay" + "github.com/vektah/graphql-go" + "github.com/vektah/graphql-go/example/starwars" + "github.com/vektah/graphql-go/relay" ) var schema *graphql.Schema diff --git a/example/starwars/starwars.go b/example/starwars/starwars.go index 0c559373940..116a2a434bf 100644 --- a/example/starwars/starwars.go +++ b/example/starwars/starwars.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - graphql "github.com/neelance/graphql-go" + graphql "github.com/vektah/graphql-go" ) var Schema = ` diff --git a/gqltesting/testing.go b/gqltesting/testing.go index 56f90e4cd3e..e66cfc1f47b 100644 --- a/gqltesting/testing.go +++ b/gqltesting/testing.go @@ -7,7 +7,7 @@ import ( "strconv" "testing" - graphql "github.com/neelance/graphql-go" + graphql "github.com/vektah/graphql-go" ) // Test is a GraphQL test case to be used with RunTest(s). diff --git a/graphql.go b/graphql.go index f63242facbe..54aa6748d1a 100644 --- a/graphql.go +++ b/graphql.go @@ -6,17 +6,17 @@ import ( "encoding/json" - "github.com/neelance/graphql-go/errors" - "github.com/neelance/graphql-go/internal/common" - "github.com/neelance/graphql-go/internal/exec" - "github.com/neelance/graphql-go/internal/exec/resolvable" - "github.com/neelance/graphql-go/internal/exec/selected" - "github.com/neelance/graphql-go/internal/query" - "github.com/neelance/graphql-go/internal/schema" - "github.com/neelance/graphql-go/internal/validation" - "github.com/neelance/graphql-go/introspection" - "github.com/neelance/graphql-go/log" - "github.com/neelance/graphql-go/trace" + "github.com/vektah/graphql-go/errors" + "github.com/vektah/graphql-go/internal/common" + "github.com/vektah/graphql-go/internal/exec" + "github.com/vektah/graphql-go/internal/exec/resolvable" + "github.com/vektah/graphql-go/internal/exec/selected" + "github.com/vektah/graphql-go/internal/query" + "github.com/vektah/graphql-go/internal/schema" + "github.com/vektah/graphql-go/internal/validation" + "github.com/vektah/graphql-go/introspection" + "github.com/vektah/graphql-go/log" + "github.com/vektah/graphql-go/trace" ) // ParseSchema parses a GraphQL schema and attaches the given root resolver. It returns an error if diff --git a/graphql_test.go b/graphql_test.go index 8e581afbc00..7db76ccd649 100644 --- a/graphql_test.go +++ b/graphql_test.go @@ -5,9 +5,9 @@ import ( "testing" "time" - "github.com/neelance/graphql-go" - "github.com/neelance/graphql-go/example/starwars" - "github.com/neelance/graphql-go/gqltesting" + "github.com/vektah/graphql-go" + "github.com/vektah/graphql-go/example/starwars" + "github.com/vektah/graphql-go/gqltesting" ) type helloWorldResolver1 struct{} diff --git a/internal/common/lexer.go b/internal/common/lexer.go index f67dc31e57f..32efed81b10 100644 --- a/internal/common/lexer.go +++ b/internal/common/lexer.go @@ -4,7 +4,7 @@ import ( "fmt" "text/scanner" - "github.com/neelance/graphql-go/errors" + "github.com/vektah/graphql-go/errors" ) type syntaxError string diff --git a/internal/common/literals.go b/internal/common/literals.go index d1c84e3ac57..73db1cfeb1f 100644 --- a/internal/common/literals.go +++ b/internal/common/literals.go @@ -5,7 +5,7 @@ import ( "strings" "text/scanner" - "github.com/neelance/graphql-go/errors" + "github.com/vektah/graphql-go/errors" ) type Literal interface { diff --git a/internal/common/types.go b/internal/common/types.go index 6a017f56efc..7b90de880be 100644 --- a/internal/common/types.go +++ b/internal/common/types.go @@ -1,7 +1,7 @@ package common import ( - "github.com/neelance/graphql-go/errors" + "github.com/vektah/graphql-go/errors" ) type Type interface { diff --git a/internal/common/values.go b/internal/common/values.go index 794f68dedb5..08452ee43eb 100644 --- a/internal/common/values.go +++ b/internal/common/values.go @@ -1,7 +1,7 @@ package common import ( - "github.com/neelance/graphql-go/errors" + "github.com/vektah/graphql-go/errors" ) type InputValue struct { diff --git a/internal/exec/exec.go b/internal/exec/exec.go index 39b6456a073..94cfb34de4e 100644 --- a/internal/exec/exec.go +++ b/internal/exec/exec.go @@ -7,14 +7,14 @@ import ( "reflect" "sync" - "github.com/neelance/graphql-go/errors" - "github.com/neelance/graphql-go/internal/common" - "github.com/neelance/graphql-go/internal/exec/resolvable" - "github.com/neelance/graphql-go/internal/exec/selected" - "github.com/neelance/graphql-go/internal/query" - "github.com/neelance/graphql-go/internal/schema" - "github.com/neelance/graphql-go/log" - "github.com/neelance/graphql-go/trace" + "github.com/vektah/graphql-go/errors" + "github.com/vektah/graphql-go/internal/common" + "github.com/vektah/graphql-go/internal/exec/resolvable" + "github.com/vektah/graphql-go/internal/exec/selected" + "github.com/vektah/graphql-go/internal/query" + "github.com/vektah/graphql-go/internal/schema" + "github.com/vektah/graphql-go/log" + "github.com/vektah/graphql-go/trace" ) type Request struct { diff --git a/internal/exec/packer/packer.go b/internal/exec/packer/packer.go index 02b9d832b71..82690433c23 100644 --- a/internal/exec/packer/packer.go +++ b/internal/exec/packer/packer.go @@ -6,9 +6,9 @@ import ( "reflect" "strings" - "github.com/neelance/graphql-go/errors" - "github.com/neelance/graphql-go/internal/common" - "github.com/neelance/graphql-go/internal/schema" + "github.com/vektah/graphql-go/errors" + "github.com/vektah/graphql-go/internal/common" + "github.com/vektah/graphql-go/internal/schema" ) type packer interface { diff --git a/internal/exec/resolvable/meta.go b/internal/exec/resolvable/meta.go index f9b0bb92c32..09cd16096ce 100644 --- a/internal/exec/resolvable/meta.go +++ b/internal/exec/resolvable/meta.go @@ -4,9 +4,9 @@ import ( "fmt" "reflect" - "github.com/neelance/graphql-go/internal/common" - "github.com/neelance/graphql-go/internal/schema" - "github.com/neelance/graphql-go/introspection" + "github.com/vektah/graphql-go/internal/common" + "github.com/vektah/graphql-go/internal/schema" + "github.com/vektah/graphql-go/introspection" ) var MetaSchema *Object diff --git a/internal/exec/resolvable/resolvable.go b/internal/exec/resolvable/resolvable.go index c681cf208ab..6cef644ab84 100644 --- a/internal/exec/resolvable/resolvable.go +++ b/internal/exec/resolvable/resolvable.go @@ -6,9 +6,9 @@ import ( "reflect" "strings" - "github.com/neelance/graphql-go/internal/common" - "github.com/neelance/graphql-go/internal/exec/packer" - "github.com/neelance/graphql-go/internal/schema" + "github.com/vektah/graphql-go/internal/common" + "github.com/vektah/graphql-go/internal/exec/packer" + "github.com/vektah/graphql-go/internal/schema" ) type Schema struct { diff --git a/internal/exec/selected/selected.go b/internal/exec/selected/selected.go index eecdcf387d8..7388fc3bfc8 100644 --- a/internal/exec/selected/selected.go +++ b/internal/exec/selected/selected.go @@ -5,13 +5,13 @@ import ( "reflect" "sync" - "github.com/neelance/graphql-go/errors" - "github.com/neelance/graphql-go/internal/common" - "github.com/neelance/graphql-go/internal/exec/packer" - "github.com/neelance/graphql-go/internal/exec/resolvable" - "github.com/neelance/graphql-go/internal/query" - "github.com/neelance/graphql-go/internal/schema" - "github.com/neelance/graphql-go/introspection" + "github.com/vektah/graphql-go/errors" + "github.com/vektah/graphql-go/internal/common" + "github.com/vektah/graphql-go/internal/exec/packer" + "github.com/vektah/graphql-go/internal/exec/resolvable" + "github.com/vektah/graphql-go/internal/query" + "github.com/vektah/graphql-go/internal/schema" + "github.com/vektah/graphql-go/introspection" ) type Request struct { diff --git a/internal/query/query.go b/internal/query/query.go index f11b1b777e9..87cc87ae72f 100644 --- a/internal/query/query.go +++ b/internal/query/query.go @@ -5,8 +5,8 @@ import ( "strings" "text/scanner" - "github.com/neelance/graphql-go/errors" - "github.com/neelance/graphql-go/internal/common" + "github.com/vektah/graphql-go/errors" + "github.com/vektah/graphql-go/internal/common" ) type Document struct { diff --git a/internal/schema/schema.go b/internal/schema/schema.go index 0cada3a9a05..5fae6ecd018 100644 --- a/internal/schema/schema.go +++ b/internal/schema/schema.go @@ -5,8 +5,8 @@ import ( "strings" "text/scanner" - "github.com/neelance/graphql-go/errors" - "github.com/neelance/graphql-go/internal/common" + "github.com/vektah/graphql-go/errors" + "github.com/vektah/graphql-go/internal/common" ) type Schema struct { diff --git a/internal/tests/all_test.go b/internal/tests/all_test.go index 7d31673f3b1..22c623b06da 100644 --- a/internal/tests/all_test.go +++ b/internal/tests/all_test.go @@ -8,10 +8,10 @@ import ( "encoding/json" - "github.com/neelance/graphql-go/errors" - "github.com/neelance/graphql-go/internal/query" - "github.com/neelance/graphql-go/internal/schema" - "github.com/neelance/graphql-go/internal/validation" + "github.com/vektah/graphql-go/errors" + "github.com/vektah/graphql-go/internal/query" + "github.com/vektah/graphql-go/internal/schema" + "github.com/vektah/graphql-go/internal/validation" ) type Test struct { diff --git a/internal/validation/validation.go b/internal/validation/validation.go index a537d458ff5..2912e6ed926 100644 --- a/internal/validation/validation.go +++ b/internal/validation/validation.go @@ -8,10 +8,10 @@ import ( "strings" "text/scanner" - "github.com/neelance/graphql-go/errors" - "github.com/neelance/graphql-go/internal/common" - "github.com/neelance/graphql-go/internal/query" - "github.com/neelance/graphql-go/internal/schema" + "github.com/vektah/graphql-go/errors" + "github.com/vektah/graphql-go/internal/common" + "github.com/vektah/graphql-go/internal/query" + "github.com/vektah/graphql-go/internal/schema" ) type varSet map[*common.InputValue]struct{} diff --git a/introspection.go b/introspection.go index f72a7700fc8..5f8beeadb65 100644 --- a/introspection.go +++ b/introspection.go @@ -4,8 +4,8 @@ import ( "context" "encoding/json" - "github.com/neelance/graphql-go/internal/exec/resolvable" - "github.com/neelance/graphql-go/introspection" + "github.com/vektah/graphql-go/internal/exec/resolvable" + "github.com/vektah/graphql-go/introspection" ) // Inspect allows inspection of the given schema. diff --git a/introspection/introspection.go b/introspection/introspection.go index d2969b7afac..80294d0f6ca 100644 --- a/introspection/introspection.go +++ b/introspection/introspection.go @@ -3,8 +3,8 @@ package introspection import ( "sort" - "github.com/neelance/graphql-go/internal/common" - "github.com/neelance/graphql-go/internal/schema" + "github.com/vektah/graphql-go/internal/common" + "github.com/vektah/graphql-go/internal/schema" ) type Schema struct { diff --git a/relay/relay.go b/relay/relay.go index 61bdd93b46f..32fb76a26b3 100644 --- a/relay/relay.go +++ b/relay/relay.go @@ -8,7 +8,7 @@ import ( "net/http" "strings" - graphql "github.com/neelance/graphql-go" + graphql "github.com/vektah/graphql-go" ) func MarshalID(kind string, spec interface{}) graphql.ID { diff --git a/relay/relay_test.go b/relay/relay_test.go index 72d8d51b400..89e78eabf52 100644 --- a/relay/relay_test.go +++ b/relay/relay_test.go @@ -5,9 +5,9 @@ import ( "strings" "testing" - "github.com/neelance/graphql-go" - "github.com/neelance/graphql-go/example/starwars" - "github.com/neelance/graphql-go/relay" + "github.com/vektah/graphql-go" + "github.com/vektah/graphql-go/example/starwars" + "github.com/vektah/graphql-go/relay" ) var starwarsSchema = graphql.MustParseSchema(starwars.Schema, &starwars.Resolver{}) diff --git a/trace/trace.go b/trace/trace.go index 443f62a14d3..10094bb028b 100644 --- a/trace/trace.go +++ b/trace/trace.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/neelance/graphql-go/errors" - "github.com/neelance/graphql-go/introspection" + "github.com/vektah/graphql-go/errors" + "github.com/vektah/graphql-go/introspection" opentracing "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" "github.com/opentracing/opentracing-go/log"