Use attic-labs/graphql (#3216)

This commit is contained in:
Ben Kalman
2017-02-22 15:04:33 -08:00
committed by GitHub
parent b1e918d1d4
commit 449b6d6b8f
109 changed files with 590 additions and 273 deletions

View File

@@ -11,8 +11,8 @@ import (
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/types"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
)
const (

View File

@@ -13,7 +13,7 @@ import (
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/hash"
"github.com/attic-labs/noms/go/types"
"github.com/graphql-go/graphql"
"github.com/attic-labs/graphql"
)
type typeMap map[typeMapKey]graphql.Type

View File

@@ -1,7 +1,6 @@
language: go
go:
- 1.4
- 1.7
- tip

2
vendor/github.com/attic-labs/graphql/.version generated vendored Normal file
View File

@@ -0,0 +1,2 @@
https://github.com/attic-labs/graphql
2b9ae68d9ac567f26a8726b61a016e898c822ec7

View File

@@ -1,16 +1,16 @@
# graphql [![Build Status](https://travis-ci.org/graphql-go/graphql.svg)](https://travis-ci.org/graphql-go/graphql) [![GoDoc](https://godoc.org/graphql.co/graphql?status.svg)](https://godoc.org/github.com/graphql-go/graphql) [![Coverage Status](https://coveralls.io/repos/graphql-go/graphql/badge.svg?branch=master&service=github)](https://coveralls.io/github/graphql-go/graphql?branch=master) [![Join the chat at https://gitter.im/chris-ramon/graphql](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/graphql-go/graphql?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# graphql [![Build Status](https://travis-ci.org/graphql-go/graphql.svg)](https://travis-ci.org/graphql-go/graphql) [![GoDoc](https://godoc.org/graphql.co/graphql?status.svg)](https://godoc.org/github.com/attic-labs/graphql) [![Coverage Status](https://coveralls.io/repos/graphql-go/graphql/badge.svg?branch=master&service=github)](https://coveralls.io/github/graphql-go/graphql?branch=master) [![Join the chat at https://gitter.im/chris-ramon/graphql](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/graphql-go/graphql?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
A *work-in-progress* implementation of GraphQL for Go.
### Documentation
godoc: https://godoc.org/github.com/graphql-go/graphql
godoc: https://godoc.org/github.com/attic-labs/graphql
### Getting Started
To install the library, run:
```bash
go get github.com/graphql-go/graphql
go get github.com/attic-labs/graphql
```
The following is a simple example which defines a schema with a single `hello` string-type field and a `Resolve` method which returns the string `world`. A GraphQL query is performed against this schema with the resulting output printed in JSON format.
@@ -23,7 +23,7 @@ import (
"fmt"
"log"
"github.com/graphql-go/graphql"
"github.com/attic-labs/graphql"
)
func main() {
@@ -58,7 +58,7 @@ func main() {
fmt.Printf("%s \n", rJSON) // {“data”:{“hello”:”world”}}
}
```
For more complex examples, refer to the [examples/](https://github.com/graphql-go/graphql/tree/master/examples/) directory and [graphql_test.go](https://github.com/graphql-go/graphql/blob/master/graphql_test.go).
For more complex examples, refer to the [examples/](https://github.com/attic-labs/graphql/tree/master/examples/) directory and [graphql_test.go](https://github.com/attic-labs/graphql/blob/master/graphql_test.go).
### Origin and Current Direction
@@ -67,8 +67,8 @@ This project was originally a port of [v0.4.3](https://github.com/graphql/graphq
### Third Party Libraries
| Name | Author | Description |
|:-------------:|:-------------:|:------------:|
| [graphql-go-handler](https://github.com/graphql-go/graphql-go-handler) | [Hafiz Ismail](https://github.com/sogko) | Middleware to handle GraphQL queries through HTTP requests. |
| [graphql-relay-go](https://github.com/graphql-go/graphql-relay-go) | [Hafiz Ismail](https://github.com/sogko) | Lib to construct a graphql-go server supporting react-relay. |
| [graphql-go-handler](https://github.com/attic-labs/graphql-go-handler) | [Hafiz Ismail](https://github.com/sogko) | Middleware to handle GraphQL queries through HTTP requests. |
| [graphql-relay-go](https://github.com/attic-labs/graphql-relay-go) | [Hafiz Ismail](https://github.com/sogko) | Lib to construct a graphql-go server supporting react-relay. |
| [golang-relay-starter-kit](https://github.com/sogko/golang-relay-starter-kit) | [Hafiz Ismail](https://github.com/sogko) | Barebones starting point for a Relay application with Golang GraphQL server. |
### Blog Posts
@@ -84,7 +84,7 @@ This project was originally a port of [v0.4.3](https://github.com/graphql/graphq
- [x] Executor
- [x] Validator
- [ ] Examples
- [ ] Basic Usage (see: [PR-#21](https://github.com/graphql-go/graphql/pull/21))
- [ ] Basic Usage (see: [PR-#21](https://github.com/attic-labs/graphql/pull/21))
- [ ] React/Relay
- [ ] Alpha Release (v0.1)

View File

@@ -4,10 +4,10 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/location"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/location"
"github.com/attic-labs/graphql/testutil"
)
type testDog struct {

View File

@@ -5,7 +5,7 @@ import (
"reflect"
"regexp"
"github.com/graphql-go/graphql/language/ast"
"github.com/attic-labs/graphql/language/ast"
"golang.org/x/net/context"
)

View File

@@ -5,8 +5,8 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/testutil"
)
var blogImage = graphql.NewObject(graphql.ObjectConfig{

View File

@@ -4,10 +4,10 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/location"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/location"
"github.com/attic-labs/graphql/testutil"
)
var directivesTestSchema, _ = graphql.NewSchema(graphql.SchemaConfig{

View File

@@ -4,10 +4,10 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/location"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/location"
"github.com/attic-labs/graphql/testutil"
)
var enumTypeTestColorType = graphql.NewEnum(graphql.EnumConfig{

View File

@@ -6,7 +6,7 @@ import (
"log"
"net/http"
"github.com/graphql-go/graphql"
"github.com/attic-labs/graphql"
"golang.org/x/net/context"
)

View File

@@ -5,7 +5,7 @@ import (
"fmt"
"log"
"github.com/graphql-go/graphql"
"github.com/attic-labs/graphql"
)
func main() {

View File

@@ -6,7 +6,7 @@ import (
"io/ioutil"
"net/http"
"github.com/graphql-go/graphql"
"github.com/attic-labs/graphql"
)
type user struct {

View File

@@ -0,0 +1,40 @@
Basically, if we have `data.json` like this:
[
{ "id": "1", "name": "Dan" },
{ "id": "2", "name": "Lee" },
{ "id": "3", "name": "Nick" }
]
... and `go run main.go`, we can query records:
$ curl -g 'http://localhost:8080/graphql?query={user(name:"Dan"){id}}'
{"data":{"user":{"id":"1"}}}
... now let's give Dan a surname:
[
{ "id": "1", "name": "Dan", "surname": "Jones" },
{ "id": "2", "name": "Lee" },
{ "id": "3", "name": "Nick" }
]
... and kick the server:
kill -SIGUSR1 52114
And ask for Dan's surname:
$ curl -g 'http://localhost:8080/graphql?query={user(name:"Dan"){id,surname}}'
{"data":{"user":{"id":"1","surname":"Jones"}}}
... or ask Jones's name and ID:
$ curl -g 'http://localhost:8080/graphql?query={user(surname:"Jones"){id,name}}'
{"data":{"user":{"id":"1","name":"Dan"}}}
If you look at `main.go`, the file is not field-aware. That is, all it knows is
how to work with `[]map[string]string` type.
With this, we are not that far from exposing dynamic fields and filters which
fully depend on what we have stored, all without changing our tooling.

View File

@@ -0,0 +1,15 @@
[
{
"id": "1",
"name": "Dan",
"surname": "Jones"
},
{
"id": "2",
"name": "Lee"
},
{
"id": "3",
"name": "Nick"
}
]

View File

@@ -0,0 +1,138 @@
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"os/signal"
"strconv"
"syscall"
"github.com/attic-labs/graphql"
)
/*****************************************************************************/
/* Shared data variables to allow dynamic reloads
/*****************************************************************************/
var schema graphql.Schema
const jsonDataFile = "data.json"
func handleSIGUSR1(c chan os.Signal) {
for {
<-c
fmt.Printf("Caught SIGUSR1. Reloading %s\n", jsonDataFile)
err := importJSONDataFromFile(jsonDataFile)
if err != nil {
fmt.Printf("Error: %s\n", err.Error())
return
}
}
}
func filterUser(data []map[string]interface{}, args map[string]interface{}) map[string]interface{} {
for _, user := range data {
for k, v := range args {
if user[k] != v {
goto nextuser
}
return user
}
nextuser:
}
return nil
}
func executeQuery(query string, schema graphql.Schema) *graphql.Result {
result := graphql.Do(graphql.Params{
Schema: schema,
RequestString: query,
})
if len(result.Errors) > 0 {
fmt.Printf("wrong result, unexpected errors: %v\n", result.Errors)
}
return result
}
func importJSONDataFromFile(fileName string) error {
content, err := ioutil.ReadFile(fileName)
if err != nil {
return err
}
var data []map[string]interface{}
err = json.Unmarshal(content, &data)
if err != nil {
return err
}
fields := make(graphql.Fields)
args := make(graphql.FieldConfigArgument)
for _, item := range data {
for k := range item {
fields[k] = &graphql.Field{
Type: graphql.String,
}
args[k] = &graphql.ArgumentConfig{
Type: graphql.String,
}
}
}
var userType = graphql.NewObject(
graphql.ObjectConfig{
Name: "User",
Fields: fields,
},
)
var queryType = graphql.NewObject(
graphql.ObjectConfig{
Name: "Query",
Fields: graphql.Fields{
"user": &graphql.Field{
Type: userType,
Args: args,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
return filterUser(data, p.Args), nil
},
},
},
})
schema, _ = graphql.NewSchema(
graphql.SchemaConfig{
Query: queryType,
},
)
return nil
}
func main() {
// Catch SIGUSR1 and reload the data file
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGUSR1)
go handleSIGUSR1(c)
err := importJSONDataFromFile(jsonDataFile)
if err != nil {
fmt.Printf("Error: %s\n", err.Error())
return
}
http.HandleFunc("/graphql", func(w http.ResponseWriter, r *http.Request) {
result := executeQuery(r.URL.Query()["query"][0], schema)
json.NewEncoder(w).Encode(result)
})
fmt.Println("Now server is running on port 8080")
fmt.Println("Test with Get : curl -g 'http://localhost:8080/graphql?query={user(name:\"Dan\"){id,surname}}'")
fmt.Printf("Reload json file : kill -SIGUSR1 %s\n", strconv.Itoa(os.Getpid()))
http.ListenAndServe(":8080", nil)
}

View File

@@ -5,8 +5,8 @@ import (
"fmt"
"net/http"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/testutil"
)
func main() {

View File

@@ -25,4 +25,7 @@ curl -g 'http://localhost:8080/graphql?query=mutation+_{createTodo(text:"My+new+
// To get a list of ToDo items
curl -g 'http://localhost:8080/graphql?query={todoList{id,text,done}}'
// To update a ToDo
curl -g 'http://localhost:8080/graphql?query=mutation+_{updateTodo(id:"b",text:"My+new+todo+updated",done:true){id,text,done}}'
```

View File

@@ -2,12 +2,13 @@ package main
import (
"encoding/json"
"errors"
"fmt"
"math/rand"
"net/http"
"time"
"github.com/graphql-go/graphql"
"github.com/attic-labs/graphql"
)
type Todo struct {
@@ -95,6 +96,38 @@ var rootMutation = graphql.NewObject(graphql.ObjectConfig{
return newTodo, nil
},
},
/*
curl -g 'http://localhost:8080/graphql?query=mutation+_{updateTodo(text:"My+new+todo+updated"){id,text,done}}'
*/
"updateTodo": &graphql.Field{
Type: todoType,
Args: graphql.FieldConfigArgument{
"id": &graphql.ArgumentConfig{
Type: graphql.NewNonNull(graphql.String),
},
"text": &graphql.ArgumentConfig{
Type: graphql.String,
},
"done": &graphql.ArgumentConfig{
Type: graphql.Boolean,
},
},
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
if idQuery, ok := p.Args["id"].(string); ok {
for _, todo := range TodoList {
if todo.ID == idQuery {
text, _ := p.Args["text"].(string)
done, _ := p.Args["done"].(bool)
todo.Text = text
todo.Done = done
return todo, nil
}
}
return nil, errors.New("could not find todo with that ID")
}
return nil, errors.New("could not get id from params")
},
},
},
})
@@ -171,15 +204,14 @@ func executeQuery(query string, schema graphql.Schema) *graphql.Result {
}
func main() {
http.HandleFunc("/graphql", func(w http.ResponseWriter, r *http.Request) {
result := executeQuery(r.URL.Query()["query"][0], schema)
json.NewEncoder(w).Encode(result)
})
fmt.Println("Now server is running on port 8080")
fmt.Println("Get single todo: curl -g 'http://localhost:8080/graphql?query={todo(id:\"b\"){id,text,done}}'")
fmt.Println("Create new todo: curl -g 'http://localhost:8080/graphql?query=mutation+_{createTodo(text:\"My+new+todo\"){id,text,done}}'")
fmt.Println("Update a todo: curl -g 'http://localhost:8080/graphql?query=mutation+_{updateTodo(id:\"b\",text:\"My+new+todo+updated\",done:true){id,text,done}}'")
fmt.Println("Load todo list: curl -g 'http://localhost:8080/graphql?query={todoList{id,text,done}}'")
http.ListenAndServe(":8080", nil)
}

View File

@@ -6,8 +6,8 @@ import (
"reflect"
"strings"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/ast"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/ast"
"golang.org/x/net/context"
)
@@ -24,40 +24,72 @@ type ExecuteParams struct {
}
func Execute(p ExecuteParams) (result *Result) {
result = &Result{}
exeContext, err := buildExecutionContext(BuildExecutionCtxParams{
Schema: p.Schema,
Root: p.Root,
AST: p.AST,
OperationName: p.OperationName,
Args: p.Args,
Errors: nil,
Result: result,
Context: p.Context,
})
if err != nil {
result.Errors = append(result.Errors, gqlerrors.FormatError(err))
return
// Use background context if no context was provided
ctx := p.Context
if ctx == nil {
ctx = context.Background()
}
defer func() {
if r := recover(); r != nil {
var err error
if r, ok := r.(error); ok {
err = gqlerrors.FormatError(r)
}
exeContext.Errors = append(exeContext.Errors, gqlerrors.FormatError(err))
result.Errors = exeContext.Errors
}
}()
resultChannel := make(chan *Result)
return executeOperation(ExecuteOperationParams{
ExecutionContext: exeContext,
Root: p.Root,
Operation: exeContext.Operation,
})
go func(out chan<- *Result, done <-chan struct{}) {
result := &Result{}
exeContext, err := buildExecutionContext(BuildExecutionCtxParams{
Schema: p.Schema,
Root: p.Root,
AST: p.AST,
OperationName: p.OperationName,
Args: p.Args,
Errors: nil,
Result: result,
Context: p.Context,
})
if err != nil {
result.Errors = append(result.Errors, gqlerrors.FormatError(err))
select {
case out <- result:
case <-done:
}
return
}
defer func() {
if r := recover(); r != nil {
var err error
if r, ok := r.(error); ok {
err = gqlerrors.FormatError(r)
}
exeContext.Errors = append(exeContext.Errors, gqlerrors.FormatError(err))
result.Errors = exeContext.Errors
select {
case out <- result:
case <-done:
}
}
}()
result = executeOperation(ExecuteOperationParams{
ExecutionContext: exeContext,
Root: p.Root,
Operation: exeContext.Operation,
})
select {
case out <- result:
case <-done:
}
}(resultChannel, ctx.Done())
select {
case <-ctx.Done():
result = &Result{}
result.Errors = append(result.Errors, gqlerrors.FormatError(ctx.Err()))
case r := <-resultChannel:
result = r
}
return
}
type BuildExecutionCtxParams struct {

View File

@@ -2,8 +2,8 @@ package graphql_test
import (
"encoding/json"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/testutil"
"reflect"
"testing"
)

View File

@@ -5,8 +5,8 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/testutil"
)
// TODO: have a separate package for other tests for eg `parser`

View File

@@ -6,11 +6,12 @@ import (
"fmt"
"reflect"
"testing"
"time"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/location"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/location"
"github.com/attic-labs/graphql/testutil"
"golang.org/x/net/context"
)
@@ -1639,3 +1640,56 @@ func TestGraphqlTag(t *testing.T) {
t.Fatalf("unexpected result, got: %+v, expected: %+v", expectedData, result.Data)
}
}
func TestContextDeadline(t *testing.T) {
timeout := time.Millisecond * time.Duration(100)
acceptableDelay := time.Millisecond * time.Duration(10)
expectedErrors := []gqlerrors.FormattedError{
{
Message: context.DeadlineExceeded.Error(),
Locations: []location.SourceLocation{},
},
}
// Query type includes a field that won't resolve within the deadline
var queryType = graphql.NewObject(
graphql.ObjectConfig{
Name: "Query",
Fields: graphql.Fields{
"hello": &graphql.Field{
Type: graphql.String,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
time.Sleep(2 * time.Second)
return "world", nil
},
},
},
})
schema, err := graphql.NewSchema(graphql.SchemaConfig{
Query: queryType,
})
if err != nil {
t.Fatalf("unexpected error, got: %v", err)
}
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
startTime := time.Now()
result := graphql.Do(graphql.Params{
Schema: schema,
RequestString: "{hello}",
Context: ctx,
})
duration := time.Since(startTime)
if duration > timeout+acceptableDelay {
t.Fatalf("graphql.Do completed in %s, should have completed in %s", duration, timeout)
}
if !result.HasErrors() || len(result.Errors) == 0 {
t.Fatalf("Result should include errors when deadline is exceeded")
}
if !reflect.DeepEqual(expectedErrors, result.Errors) {
t.Fatalf("Unexpected result, Diff: %v", testutil.Diff(expectedErrors, result.Errors))
}
}

View File

@@ -3,9 +3,9 @@ package gqlerrors
import (
"fmt"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/location"
"github.com/graphql-go/graphql/language/source"
"github.com/attic-labs/graphql/language/ast"
"github.com/attic-labs/graphql/language/location"
"github.com/attic-labs/graphql/language/source"
)
type Error struct {

View File

@@ -3,7 +3,7 @@ package gqlerrors
import (
"errors"
"github.com/graphql-go/graphql/language/location"
"github.com/attic-labs/graphql/language/location"
)
type FormattedError struct {

View File

@@ -2,7 +2,7 @@ package gqlerrors
import (
"errors"
"github.com/graphql-go/graphql/language/ast"
"github.com/attic-labs/graphql/language/ast"
)
// NewLocatedError creates a graphql.Error with location info

View File

@@ -5,9 +5,9 @@ import (
"regexp"
"strings"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/location"
"github.com/graphql-go/graphql/language/source"
"github.com/attic-labs/graphql/language/ast"
"github.com/attic-labs/graphql/language/location"
"github.com/attic-labs/graphql/language/source"
)
func NewSyntaxError(s *source.Source, position int, description string) *Error {

View File

@@ -1,9 +1,9 @@
package graphql
import (
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/parser"
"github.com/graphql-go/graphql/language/source"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/parser"
"github.com/attic-labs/graphql/language/source"
"golang.org/x/net/context"
)

View File

@@ -4,8 +4,8 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/testutil"
"golang.org/x/net/context"
)

View File

@@ -4,8 +4,8 @@ import (
"fmt"
"reflect"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/printer"
"github.com/attic-labs/graphql/language/ast"
"github.com/attic-labs/graphql/language/printer"
)
const (

View File

@@ -4,10 +4,10 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/location"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/location"
"github.com/attic-labs/graphql/testutil"
)
func g(t *testing.T, p graphql.Params) *graphql.Result {

View File

@@ -1,7 +1,7 @@
package ast
import (
"github.com/graphql-go/graphql/language/kinds"
"github.com/attic-labs/graphql/language/kinds"
)
// Argument implements Node

View File

@@ -1,7 +1,7 @@
package ast
import (
"github.com/graphql-go/graphql/language/kinds"
"github.com/attic-labs/graphql/language/kinds"
)
type Definition interface {

View File

@@ -1,7 +1,7 @@
package ast
import (
"github.com/graphql-go/graphql/language/kinds"
"github.com/attic-labs/graphql/language/kinds"
)
// Directive implements Node

View File

@@ -1,7 +1,7 @@
package ast
import (
"github.com/graphql-go/graphql/language/kinds"
"github.com/attic-labs/graphql/language/kinds"
)
// Document implements Node

View File

@@ -1,7 +1,7 @@
package ast
import (
"github.com/graphql-go/graphql/language/source"
"github.com/attic-labs/graphql/language/source"
)
type Location struct {

View File

@@ -1,7 +1,7 @@
package ast
import (
"github.com/graphql-go/graphql/language/kinds"
"github.com/attic-labs/graphql/language/kinds"
)
// Name implements Node

View File

@@ -1,7 +1,7 @@
package ast
import (
"github.com/graphql-go/graphql/language/kinds"
"github.com/attic-labs/graphql/language/kinds"
)
type Selection interface {

View File

@@ -1,7 +1,7 @@
package ast
import (
"github.com/graphql-go/graphql/language/kinds"
"github.com/attic-labs/graphql/language/kinds"
)
type TypeDefinition interface {

View File

@@ -1,7 +1,7 @@
package ast
import (
"github.com/graphql-go/graphql/language/kinds"
"github.com/attic-labs/graphql/language/kinds"
)
type Type interface {

View File

@@ -1,7 +1,7 @@
package ast
import (
"github.com/graphql-go/graphql/language/kinds"
"github.com/attic-labs/graphql/language/kinds"
)
type Value interface {

View File

@@ -5,8 +5,8 @@ import (
"fmt"
"unicode/utf8"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/source"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/source"
)
const (

View File

@@ -4,7 +4,7 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql/language/source"
"github.com/attic-labs/graphql/language/source"
)
type Test struct {

View File

@@ -3,7 +3,7 @@ package location
import (
"regexp"
"github.com/graphql-go/graphql/language/source"
"github.com/attic-labs/graphql/language/source"
)
type SourceLocation struct {

View File

@@ -3,10 +3,10 @@ package parser
import (
"fmt"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/lexer"
"github.com/graphql-go/graphql/language/source"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/ast"
"github.com/attic-labs/graphql/language/lexer"
"github.com/attic-labs/graphql/language/source"
)
type parseFn func(parser *Parser) (interface{}, error)

View File

@@ -7,11 +7,11 @@ import (
"strings"
"testing"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/location"
"github.com/graphql-go/graphql/language/printer"
"github.com/graphql-go/graphql/language/source"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/ast"
"github.com/attic-labs/graphql/language/location"
"github.com/attic-labs/graphql/language/printer"
"github.com/attic-labs/graphql/language/source"
)
func TestBadToken(t *testing.T) {

View File

@@ -4,10 +4,10 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/location"
"github.com/graphql-go/graphql/language/source"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/ast"
"github.com/attic-labs/graphql/language/location"
"github.com/attic-labs/graphql/language/source"
)
func parse(t *testing.T, query string) *ast.Document {

View File

@@ -4,8 +4,8 @@ import (
"fmt"
"strings"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/visitor"
"github.com/attic-labs/graphql/language/ast"
"github.com/attic-labs/graphql/language/visitor"
"reflect"
)

View File

@@ -5,10 +5,10 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/parser"
"github.com/graphql-go/graphql/language/printer"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql/language/ast"
"github.com/attic-labs/graphql/language/parser"
"github.com/attic-labs/graphql/language/printer"
"github.com/attic-labs/graphql/testutil"
)
func parse(t *testing.T, query string) *ast.Document {

View File

@@ -5,9 +5,9 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/printer"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql/language/ast"
"github.com/attic-labs/graphql/language/printer"
"github.com/attic-labs/graphql/testutil"
)
func TestSchemaPrinter_PrintsMinimalAST(t *testing.T) {

View File

@@ -1,7 +1,7 @@
package typeInfo
import (
"github.com/graphql-go/graphql/language/ast"
"github.com/attic-labs/graphql/language/ast"
)
// TypeInfoI defines the interface for TypeInfo Implementation

View File

@@ -3,8 +3,8 @@ package visitor
import (
"encoding/json"
"fmt"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/typeInfo"
"github.com/attic-labs/graphql/language/ast"
"github.com/attic-labs/graphql/language/typeInfo"
"reflect"
)

View File

@@ -6,13 +6,13 @@ import (
"testing"
"fmt"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/kinds"
"github.com/graphql-go/graphql/language/parser"
"github.com/graphql-go/graphql/language/printer"
"github.com/graphql-go/graphql/language/visitor"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/language/ast"
"github.com/attic-labs/graphql/language/kinds"
"github.com/attic-labs/graphql/language/parser"
"github.com/attic-labs/graphql/language/printer"
"github.com/attic-labs/graphql/language/visitor"
"github.com/attic-labs/graphql/testutil"
)
func parse(t *testing.T, query string) *ast.Document {

View File

@@ -4,10 +4,10 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/location"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/location"
"github.com/attic-labs/graphql/testutil"
)
func checkList(t *testing.T, testType graphql.Type, testData interface{}, expected *graphql.Result) {

View File

@@ -2,8 +2,8 @@ package graphql
import (
"errors"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/ast"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/ast"
)
func NewLocatedError(err interface{}, nodes []ast.Node) *gqlerrors.Error {

View File

@@ -4,10 +4,10 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/location"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/location"
"github.com/attic-labs/graphql/testutil"
)
// testNumberHolder maps to numberHolderType

View File

@@ -5,10 +5,10 @@ import (
"sort"
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/location"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/location"
"github.com/attic-labs/graphql/testutil"
)
var syncError = "sync"

View File

@@ -2,11 +2,11 @@ package graphql
import (
"fmt"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/kinds"
"github.com/graphql-go/graphql/language/printer"
"github.com/graphql-go/graphql/language/visitor"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/ast"
"github.com/attic-labs/graphql/language/kinds"
"github.com/attic-labs/graphql/language/printer"
"github.com/attic-labs/graphql/language/visitor"
"sort"
"strings"
)
@@ -15,12 +15,12 @@ import (
var SpecifiedRules = []ValidationRuleFn{
ArgumentsOfCorrectTypeRule,
DefaultValuesOfCorrectTypeRule,
FieldsOnCorrectTypeRule,
// FieldsOnCorrectTypeRule, <-- commented out for Attic
FragmentsOnCompositeTypesRule,
KnownArgumentNamesRule,
KnownDirectivesRule,
KnownFragmentNamesRule,
KnownTypeNamesRule,
// KnownTypeNamesRule, <-- commented out for Attic
LoneAnonymousOperationRule,
NoFragmentCyclesRule,
NoUndefinedVariablesRule,

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_ArgValuesOfCorrectType_ValidValue_GoodIntValue(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_VariableDefaultValuesOfCorrectType_VariablesWithNoDefaultValues(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_FieldsOnCorrectType_ObjectFieldSelection(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_FragmentsOnCompositeTypes_ObjectIsValidFragmentType(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_KnownArgumentNames_SingleArgIsKnown(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_KnownDirectives_WithNoDirectives(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_KnownFragmentNames_KnownFragmentNamesAreValid(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_KnownTypeNames_KnownTypeNamesAreValid(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_AnonymousOperationMustBeAlone_NoOperations(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_NoCircularFragmentSpreads_SingleReferenceIsValid(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_NoUndefinedVariables_AllVariablesDefined(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_NoUnusedFragments_AllFragmentNamesAreUsed(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_NoUnusedVariables_UsesAllVariables(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_OverlappingFieldsCanBeMerged_UniqueFields(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_PossibleFragmentSpreads_OfTheSameObject(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_ProvidedNonNullArguments_IgnoresUnknownArguments(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_ScalarLeafs_ValidScalarSelection(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_UniqueArgumentNames_NoArgumentsOnField(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_UniqueFragmentNames_NoFragments(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_UniqueInputFieldNames_InputObjectWithFields(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_UniqueOperationNames_NoOperations(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_UniqueVariableNames_UniqueVariableNames(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_VariablesAreInputTypes_(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package graphql_test
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/testutil"
)
func TestValidate_VariablesInAllowedPosition_BooleanToBoolean(t *testing.T) {

View File

@@ -5,7 +5,7 @@ import (
"math"
"strconv"
"github.com/graphql-go/graphql/language/ast"
"github.com/attic-labs/graphql/language/ast"
)
// As per the GraphQL Spec, Integers are only treated as valid when a valid

View File

@@ -5,7 +5,7 @@ import (
"reflect"
"testing"
"github.com/graphql-go/graphql"
"github.com/attic-labs/graphql"
)
type intSerializationTest struct {

View File

@@ -3,11 +3,11 @@ package testutil
import (
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/gqlerrors"
"github.com/graphql-go/graphql/language/location"
"github.com/graphql-go/graphql/language/parser"
"github.com/graphql-go/graphql/language/source"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/gqlerrors"
"github.com/attic-labs/graphql/language/location"
"github.com/attic-labs/graphql/language/parser"
"github.com/attic-labs/graphql/language/source"
"reflect"
)

View File

@@ -6,9 +6,9 @@ import (
"strconv"
"testing"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/parser"
"github.com/attic-labs/graphql"
"github.com/attic-labs/graphql/language/ast"
"github.com/attic-labs/graphql/language/parser"
"github.com/kr/pretty"
)

View File

@@ -3,7 +3,7 @@ package testutil_test
import (
"testing"
"github.com/graphql-go/graphql/testutil"
"github.com/attic-labs/graphql/testutil"
)
func TestSubsetSlice_Simple(t *testing.T) {

Some files were not shown because too many files have changed in this diff Show More