mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-09 03:09:12 -06:00
Use attic-labs/graphql (#3216)
This commit is contained in:
@@ -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 (
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.4
|
||||
- 1.7
|
||||
- tip
|
||||
|
||||
2
vendor/github.com/attic-labs/graphql/.version
generated
vendored
Normal file
2
vendor/github.com/attic-labs/graphql/.version
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
https://github.com/attic-labs/graphql
|
||||
2b9ae68d9ac567f26a8726b61a016e898c822ec7
|
||||
@@ -1,16 +1,16 @@
|
||||
# graphql [](https://travis-ci.org/graphql-go/graphql) [](https://godoc.org/github.com/graphql-go/graphql) [](https://coveralls.io/github/graphql-go/graphql?branch=master) [](https://gitter.im/graphql-go/graphql?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
# graphql [](https://travis-ci.org/graphql-go/graphql) [](https://godoc.org/github.com/attic-labs/graphql) [](https://coveralls.io/github/graphql-go/graphql?branch=master) [](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)
|
||||
|
||||
@@ -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 {
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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{
|
||||
@@ -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{
|
||||
@@ -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{
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/graphql-go/graphql"
|
||||
"github.com/attic-labs/graphql"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/graphql-go/graphql"
|
||||
"github.com/attic-labs/graphql"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/graphql-go/graphql"
|
||||
"github.com/attic-labs/graphql"
|
||||
)
|
||||
|
||||
type user struct {
|
||||
40
vendor/github.com/attic-labs/graphql/examples/httpdynamic/README.md
generated
vendored
Normal file
40
vendor/github.com/attic-labs/graphql/examples/httpdynamic/README.md
generated
vendored
Normal 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.
|
||||
15
vendor/github.com/attic-labs/graphql/examples/httpdynamic/data.json
generated
vendored
Normal file
15
vendor/github.com/attic-labs/graphql/examples/httpdynamic/data.json
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"id": "1",
|
||||
"name": "Dan",
|
||||
"surname": "Jones"
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"name": "Lee"
|
||||
},
|
||||
{
|
||||
"id": "3",
|
||||
"name": "Nick"
|
||||
}
|
||||
]
|
||||
138
vendor/github.com/attic-labs/graphql/examples/httpdynamic/main.go
generated
vendored
Normal file
138
vendor/github.com/attic-labs/graphql/examples/httpdynamic/main.go
generated
vendored
Normal 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)
|
||||
}
|
||||
@@ -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() {
|
||||
@@ -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}}'
|
||||
```
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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 {
|
||||
@@ -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"
|
||||
)
|
||||
@@ -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`
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
@@ -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 {
|
||||
@@ -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
|
||||
@@ -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 {
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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 (
|
||||
@@ -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 {
|
||||
@@ -1,7 +1,7 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"github.com/graphql-go/graphql/language/kinds"
|
||||
"github.com/attic-labs/graphql/language/kinds"
|
||||
)
|
||||
|
||||
// Argument implements Node
|
||||
@@ -1,7 +1,7 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"github.com/graphql-go/graphql/language/kinds"
|
||||
"github.com/attic-labs/graphql/language/kinds"
|
||||
)
|
||||
|
||||
type Definition interface {
|
||||
@@ -1,7 +1,7 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"github.com/graphql-go/graphql/language/kinds"
|
||||
"github.com/attic-labs/graphql/language/kinds"
|
||||
)
|
||||
|
||||
// Directive implements Node
|
||||
@@ -1,7 +1,7 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"github.com/graphql-go/graphql/language/kinds"
|
||||
"github.com/attic-labs/graphql/language/kinds"
|
||||
)
|
||||
|
||||
// Document implements Node
|
||||
@@ -1,7 +1,7 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"github.com/graphql-go/graphql/language/source"
|
||||
"github.com/attic-labs/graphql/language/source"
|
||||
)
|
||||
|
||||
type Location struct {
|
||||
@@ -1,7 +1,7 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"github.com/graphql-go/graphql/language/kinds"
|
||||
"github.com/attic-labs/graphql/language/kinds"
|
||||
)
|
||||
|
||||
// Name implements Node
|
||||
@@ -1,7 +1,7 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"github.com/graphql-go/graphql/language/kinds"
|
||||
"github.com/attic-labs/graphql/language/kinds"
|
||||
)
|
||||
|
||||
type Selection interface {
|
||||
@@ -1,7 +1,7 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"github.com/graphql-go/graphql/language/kinds"
|
||||
"github.com/attic-labs/graphql/language/kinds"
|
||||
)
|
||||
|
||||
type TypeDefinition interface {
|
||||
@@ -1,7 +1,7 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"github.com/graphql-go/graphql/language/kinds"
|
||||
"github.com/attic-labs/graphql/language/kinds"
|
||||
)
|
||||
|
||||
type Type interface {
|
||||
@@ -1,7 +1,7 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"github.com/graphql-go/graphql/language/kinds"
|
||||
"github.com/attic-labs/graphql/language/kinds"
|
||||
)
|
||||
|
||||
type Value interface {
|
||||
@@ -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 (
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/graphql-go/graphql/language/source"
|
||||
"github.com/attic-labs/graphql/language/source"
|
||||
)
|
||||
|
||||
type Test struct {
|
||||
@@ -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 {
|
||||
@@ -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)
|
||||
@@ -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) {
|
||||
@@ -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 {
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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 {
|
||||
@@ -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) {
|
||||
@@ -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
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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 {
|
||||
@@ -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) {
|
||||
@@ -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 {
|
||||
@@ -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
|
||||
@@ -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"
|
||||
@@ -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,
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/graphql-go/graphql"
|
||||
"github.com/attic-labs/graphql"
|
||||
)
|
||||
|
||||
type intSerializationTest struct {
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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
Reference in New Issue
Block a user