From 51495a7cf7653ba9f248ced5325854d84e7a0add Mon Sep 17 00:00:00 2001 From: Naser Mirzaei Date: Sat, 25 Apr 2020 23:37:21 +0430 Subject: [PATCH] return nil schema on error --- abstract_test.go | 10 +- benchutil/list_schema.go | 2 +- benchutil/wide_schema.go | 2 +- directives_test.go | 2 +- enum_type_test.go | 8 +- examples/concurrent-resolvers/main.go | 2 +- examples/context/main.go | 2 +- examples/crud/main.go | 2 +- examples/custom-scalar-type/main.go | 2 +- examples/hello-world/main.go | 2 +- examples/http/main.go | 2 +- examples/httpdynamic/main.go | 4 +- examples/modify-context/main.go | 2 +- examples/sql-nullstring/main.go | 504 +++++++++--------- examples/todo/main.go | 2 +- executor_resolve_test.go | 2 +- executor_schema_test.go | 2 +- executor_test.go | 70 +-- extensions_test.go | 2 +- graphql_test.go | 8 +- introspection_test.go | 20 +- lists_test.go | 4 +- mutations_test.go | 4 +- nonnull_test.go | 40 +- ...s_overlapping_fields_can_be_merged_test.go | 30 +- schema.go | 22 +- testutil/rules_test_harness.go | 4 +- testutil/testutil.go | 4 +- type_comparators_internal_test.go | 2 +- union_interface_test.go | 18 +- util_test.go | 4 +- validation_test.go | 16 +- variables_test.go | 82 +-- 33 files changed, 442 insertions(+), 440 deletions(-) diff --git a/abstract_test.go b/abstract_test.go index 0a2da642..d8c819af 100644 --- a/abstract_test.go +++ b/abstract_test.go @@ -147,7 +147,7 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForInterface(t *testing.T) { } result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if len(result.Errors) != 0 { @@ -284,7 +284,7 @@ func TestAppendTypeUsedToAddRuntimeCustomScalarTypeForInterface(t *testing.T) { } result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if len(result.Errors) != 0 { @@ -384,7 +384,7 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForUnion(t *testing.T) { } result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if len(result.Errors) != 0 { @@ -523,7 +523,7 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) { } result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if !testutil.EqualResults(expected, result) { @@ -647,7 +647,7 @@ func TestResolveTypeOnUnionYieldsUsefulError(t *testing.T) { } result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if !testutil.EqualResults(expected, result) { diff --git a/benchutil/list_schema.go b/benchutil/list_schema.go index 196a7f5c..5e4d5c44 100644 --- a/benchutil/list_schema.go +++ b/benchutil/list_schema.go @@ -80,7 +80,7 @@ func ListSchemaWithXItems(x int) graphql.Schema { Query: queryType, }) - return colorSchema + return *colorSchema } var colors []color diff --git a/benchutil/wide_schema.go b/benchutil/wide_schema.go index 1177fce6..3b2f8980 100644 --- a/benchutil/wide_schema.go +++ b/benchutil/wide_schema.go @@ -33,7 +33,7 @@ func WideSchemaWithXFieldsAndYItems(x int, y int) graphql.Schema { Query: queryType, }) - return wideSchema + return *wideSchema } func generateXWideFields(x int) graphql.Fields { diff --git a/directives_test.go b/directives_test.go index 30b3028a..ad8d6124 100644 --- a/directives_test.go +++ b/directives_test.go @@ -31,7 +31,7 @@ var directivesTestData map[string]interface{} = map[string]interface{}{ func executeDirectivesTestQuery(t *testing.T, doc string) *graphql.Result { ast := testutil.TestParse(t, doc) ep := graphql.ExecuteParams{ - Schema: directivesTestSchema, + Schema: *directivesTestSchema, AST: ast, Root: directivesTestData, } diff --git a/enum_type_test.go b/enum_type_test.go index 33ad67a3..148a2f22 100644 --- a/enum_type_test.go +++ b/enum_type_test.go @@ -123,14 +123,14 @@ var enumTypeTestSchema, _ = graphql.NewSchema(graphql.SchemaConfig{ func executeEnumTypeTest(t *testing.T, query string) *graphql.Result { result := g(t, graphql.Params{ - Schema: enumTypeTestSchema, + Schema: *enumTypeTestSchema, RequestString: query, }) return result } func executeEnumTypeTestWithParams(t *testing.T, query string, params map[string]interface{}) *graphql.Result { result := g(t, graphql.Params{ - Schema: enumTypeTestSchema, + Schema: *enumTypeTestSchema, RequestString: query, VariableValues: params, }) @@ -414,7 +414,7 @@ func TestTypeSystem_EnumValues_EnumValueMayBePointer(t *testing.T) { "color": "GREEN", "foo": 1}}} result := g(t, graphql.Params{ - Schema: enumTypeTestSchema, + Schema: *enumTypeTestSchema, RequestString: query, }) if !reflect.DeepEqual(expected, result) { @@ -453,7 +453,7 @@ func TestTypeSystem_EnumValues_EnumValueMayBeNilPointer(t *testing.T) { }}, } result := g(t, graphql.Params{ - Schema: enumTypeTestSchema, + Schema: *enumTypeTestSchema, RequestString: query, }) if !reflect.DeepEqual(expected, result) { diff --git a/examples/concurrent-resolvers/main.go b/examples/concurrent-resolvers/main.go index 08a1c9ef..27dc5f35 100644 --- a/examples/concurrent-resolvers/main.go +++ b/examples/concurrent-resolvers/main.go @@ -86,7 +86,7 @@ func main() { ` result := graphql.Do(graphql.Params{ RequestString: query, - Schema: schema, + Schema: *schema, }) b, err := json.Marshal(result) if err != nil { diff --git a/examples/context/main.go b/examples/context/main.go index 149a9291..2636ac43 100644 --- a/examples/context/main.go +++ b/examples/context/main.go @@ -70,5 +70,5 @@ func init() { if err != nil { log.Fatalf("failed to create schema, error: %v", err) } - Schema = s + Schema = *s } diff --git a/examples/crud/main.go b/examples/crud/main.go index dac20bcd..14548165 100644 --- a/examples/crud/main.go +++ b/examples/crud/main.go @@ -226,7 +226,7 @@ func executeQuery(query string, schema graphql.Schema) *graphql.Result { func main() { http.HandleFunc("/product", func(w http.ResponseWriter, r *http.Request) { - result := executeQuery(r.URL.Query().Get("query"), schema) + result := executeQuery(r.URL.Query().Get("query"), *schema) json.NewEncoder(w).Encode(result) }) diff --git a/examples/custom-scalar-type/main.go b/examples/custom-scalar-type/main.go index e7203a06..7bd6ad21 100644 --- a/examples/custom-scalar-type/main.go +++ b/examples/custom-scalar-type/main.go @@ -124,7 +124,7 @@ func main() { ` */ result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, VariableValues: map[string]interface{}{ "id": "5b42ba57289", diff --git a/examples/hello-world/main.go b/examples/hello-world/main.go index d014e942..1fba52df 100644 --- a/examples/hello-world/main.go +++ b/examples/hello-world/main.go @@ -31,7 +31,7 @@ func main() { hello } ` - params := graphql.Params{Schema: schema, RequestString: query} + params := graphql.Params{Schema: *schema, RequestString: query} r := graphql.Do(params) if len(r.Errors) > 0 { log.Fatalf("failed to execute graphql operation, errors: %+v", r.Errors) diff --git a/examples/http/main.go b/examples/http/main.go index a1f2836e..666992b3 100644 --- a/examples/http/main.go +++ b/examples/http/main.go @@ -88,7 +88,7 @@ func main() { _ = importJSONDataFromFile("data.json", &data) http.HandleFunc("/graphql", func(w http.ResponseWriter, r *http.Request) { - result := executeQuery(r.URL.Query().Get("query"), schema) + result := executeQuery(r.URL.Query().Get("query"), *schema) json.NewEncoder(w).Encode(result) }) diff --git a/examples/httpdynamic/main.go b/examples/httpdynamic/main.go index ff8abb89..68e4dfc9 100644 --- a/examples/httpdynamic/main.go +++ b/examples/httpdynamic/main.go @@ -17,7 +17,7 @@ import ( /* Shared data variables to allow dynamic reloads /*****************************************************************************/ -var schema graphql.Schema +var schema *graphql.Schema const jsonDataFile = "data.json" @@ -127,7 +127,7 @@ func main() { } http.HandleFunc("/graphql", func(w http.ResponseWriter, r *http.Request) { - result := executeQuery(r.URL.Query().Get("query"), schema) + result := executeQuery(r.URL.Query().Get("query"), *schema) json.NewEncoder(w).Encode(result) }) diff --git a/examples/modify-context/main.go b/examples/modify-context/main.go index 0432b3ba..eab7e785 100644 --- a/examples/modify-context/main.go +++ b/examples/modify-context/main.go @@ -65,7 +65,7 @@ func main() { Context: ctx, RequestString: "{ users { id } }", RootObject: rootObject, - Schema: schema, + Schema: *schema, }) b, err := json.Marshal(result) if err != nil { diff --git a/examples/sql-nullstring/main.go b/examples/sql-nullstring/main.go index cfcf6390..ad832287 100644 --- a/examples/sql-nullstring/main.go +++ b/examples/sql-nullstring/main.go @@ -1,252 +1,252 @@ -package main - -import ( - "database/sql" - "encoding/json" - "fmt" - "github.com/graphql-go/graphql" - "github.com/graphql-go/graphql/language/ast" - "log" -) - -// NullString to be used in place of sql.NullString -type NullString struct { - sql.NullString -} - -// MarshalJSON from the json.Marshaler interface -func (v NullString) MarshalJSON() ([]byte, error) { - if v.Valid { - return json.Marshal(v.String) - } - return json.Marshal(nil) -} - -// UnmarshalJSON from the json.Unmarshaler interface -func (v *NullString) UnmarshalJSON(data []byte) error { - var x *string - if err := json.Unmarshal(data, &x); err != nil { - return err - } - if x != nil { - v.String = *x - v.Valid = true - } else { - v.Valid = false - } - return nil -} - -// NewNullString create a new null string. Empty string evaluates to an -// "invalid" NullString -func NewNullString(value string) *NullString { - var null NullString - if value != "" { - null.String = value - null.Valid = true - return &null - } - null.Valid = false - return &null -} - -// SerializeNullString serializes `NullString` to a string -func SerializeNullString(value interface{}) interface{} { - switch value := value.(type) { - case NullString: - return value.String - case *NullString: - v := *value - return v.String - default: - return nil - } -} - -// ParseNullString parses GraphQL variables from `string` to `CustomID` -func ParseNullString(value interface{}) interface{} { - switch value := value.(type) { - case string: - return NewNullString(value) - case *string: - return NewNullString(*value) - default: - return nil - } -} - -// ParseLiteralNullString parses GraphQL AST value to `NullString`. -func ParseLiteralNullString(valueAST ast.Value) interface{} { - switch valueAST := valueAST.(type) { - case *ast.StringValue: - return NewNullString(valueAST.Value) - default: - return nil - } -} - -// NullableString graphql *Scalar type based of NullString -var NullableString = graphql.NewScalar(graphql.ScalarConfig{ - Name: "NullableString", - Description: "The `NullableString` type repesents a nullable SQL string.", - Serialize: SerializeNullString, - ParseValue: ParseNullString, - ParseLiteral: ParseLiteralNullString, -}) - -/* -CREATE TABLE persons ( - favorite_dog TEXT -- is a nullable field - ); - -*/ - -// Person noqa -type Person struct { - Name string `json:"name"` - FavoriteDog *NullString `json:"favorite_dog"` // Some people don't like dogs ¯\_(ツ)_/¯ -} - -// PersonType noqa -var PersonType = graphql.NewObject(graphql.ObjectConfig{ - Name: "Person", - Fields: graphql.Fields{ - "name": &graphql.Field{ - Type: graphql.String, - }, - "favorite_dog": &graphql.Field{ - Type: NullableString, - }, - }, -}) - -func main() { - schema, err := graphql.NewSchema(graphql.SchemaConfig{ - Query: graphql.NewObject(graphql.ObjectConfig{ - Name: "Query", - Fields: graphql.Fields{ - "people": &graphql.Field{ - Type: graphql.NewList(PersonType), - Args: graphql.FieldConfigArgument{ - "favorite_dog": &graphql.ArgumentConfig{ - Type: NullableString, - }, - }, - Resolve: func(p graphql.ResolveParams) (interface{}, error) { - dog, dogOk := p.Args["favorite_dog"].(*NullString) - people := []Person{ - Person{Name: "Alice", FavoriteDog: NewNullString("Yorkshire Terrier")}, - // `Bob`'s favorite dog will be saved as null in the database - Person{Name: "Bob", FavoriteDog: NewNullString("")}, - Person{Name: "Chris", FavoriteDog: NewNullString("French Bulldog")}, - } - switch { - case dogOk: - log.Printf("favorite_dog from arguments: %+v", dog) - dogPeople := make([]Person, 0) - for _, p := range people { - if p.FavoriteDog.Valid { - if p.FavoriteDog.String == dog.String { - dogPeople = append(dogPeople, p) - } - } - } - return dogPeople, nil - default: - return people, nil - } - }, - }, - }, - }), - }) - if err != nil { - log.Fatal(err) - } - query := ` -query { - people { - name - favorite_dog - } -}` - queryWithArgument := ` -query { - people(favorite_dog: "Yorkshire Terrier") { - name - favorite_dog - } -}` - r1 := graphql.Do(graphql.Params{ - Schema: schema, - RequestString: query, - }) - r2 := graphql.Do(graphql.Params{ - Schema: schema, - RequestString: queryWithArgument, - }) - if len(r1.Errors) > 0 { - log.Fatal(r1) - } - if len(r2.Errors) > 0 { - log.Fatal(r1) - } - b1, err := json.MarshalIndent(r1, "", " ") - b2, err := json.MarshalIndent(r2, "", " ") - if err != nil { - log.Fatal(err) - - } - fmt.Printf("\nQuery: %+v\n", string(query)) - fmt.Printf("\nResult: %+v\n", string(b1)) - fmt.Printf("\nQuery (with arguments): %+v\n", string(queryWithArgument)) - fmt.Printf("\nResult (with arguments): %+v\n", string(b2)) -} - -/* Output: -Query: -query { - people { - name - favorite_dog - } -} - -Result: { - "data": { - "people": [ - { - "favorite_dog": "Yorkshire Terrier", - "name": "Alice" - }, - { - "favorite_dog": "", - "name": "Bob" - }, - { - "favorite_dog": "French Bulldog", - "name": "Chris" - } - ] - } -} - -Query (with arguments): -query { - people(favorite_dog: "Yorkshire Terrier") { - name - favorite_dog - } -} - -Result (with arguments): { - "data": { - "people": [ - { - "favorite_dog": "Yorkshire Terrier", - "name": "Alice" - } - ] - } -} -*/ +package main + +import ( + "database/sql" + "encoding/json" + "fmt" + "github.com/graphql-go/graphql" + "github.com/graphql-go/graphql/language/ast" + "log" +) + +// NullString to be used in place of sql.NullString +type NullString struct { + sql.NullString +} + +// MarshalJSON from the json.Marshaler interface +func (v NullString) MarshalJSON() ([]byte, error) { + if v.Valid { + return json.Marshal(v.String) + } + return json.Marshal(nil) +} + +// UnmarshalJSON from the json.Unmarshaler interface +func (v *NullString) UnmarshalJSON(data []byte) error { + var x *string + if err := json.Unmarshal(data, &x); err != nil { + return err + } + if x != nil { + v.String = *x + v.Valid = true + } else { + v.Valid = false + } + return nil +} + +// NewNullString create a new null string. Empty string evaluates to an +// "invalid" NullString +func NewNullString(value string) *NullString { + var null NullString + if value != "" { + null.String = value + null.Valid = true + return &null + } + null.Valid = false + return &null +} + +// SerializeNullString serializes `NullString` to a string +func SerializeNullString(value interface{}) interface{} { + switch value := value.(type) { + case NullString: + return value.String + case *NullString: + v := *value + return v.String + default: + return nil + } +} + +// ParseNullString parses GraphQL variables from `string` to `CustomID` +func ParseNullString(value interface{}) interface{} { + switch value := value.(type) { + case string: + return NewNullString(value) + case *string: + return NewNullString(*value) + default: + return nil + } +} + +// ParseLiteralNullString parses GraphQL AST value to `NullString`. +func ParseLiteralNullString(valueAST ast.Value) interface{} { + switch valueAST := valueAST.(type) { + case *ast.StringValue: + return NewNullString(valueAST.Value) + default: + return nil + } +} + +// NullableString graphql *Scalar type based of NullString +var NullableString = graphql.NewScalar(graphql.ScalarConfig{ + Name: "NullableString", + Description: "The `NullableString` type repesents a nullable SQL string.", + Serialize: SerializeNullString, + ParseValue: ParseNullString, + ParseLiteral: ParseLiteralNullString, +}) + +/* +CREATE TABLE persons ( + favorite_dog TEXT -- is a nullable field + ); + +*/ + +// Person noqa +type Person struct { + Name string `json:"name"` + FavoriteDog *NullString `json:"favorite_dog"` // Some people don't like dogs ¯\_(ツ)_/¯ +} + +// PersonType noqa +var PersonType = graphql.NewObject(graphql.ObjectConfig{ + Name: "Person", + Fields: graphql.Fields{ + "name": &graphql.Field{ + Type: graphql.String, + }, + "favorite_dog": &graphql.Field{ + Type: NullableString, + }, + }, +}) + +func main() { + schema, err := graphql.NewSchema(graphql.SchemaConfig{ + Query: graphql.NewObject(graphql.ObjectConfig{ + Name: "Query", + Fields: graphql.Fields{ + "people": &graphql.Field{ + Type: graphql.NewList(PersonType), + Args: graphql.FieldConfigArgument{ + "favorite_dog": &graphql.ArgumentConfig{ + Type: NullableString, + }, + }, + Resolve: func(p graphql.ResolveParams) (interface{}, error) { + dog, dogOk := p.Args["favorite_dog"].(*NullString) + people := []Person{ + Person{Name: "Alice", FavoriteDog: NewNullString("Yorkshire Terrier")}, + // `Bob`'s favorite dog will be saved as null in the database + Person{Name: "Bob", FavoriteDog: NewNullString("")}, + Person{Name: "Chris", FavoriteDog: NewNullString("French Bulldog")}, + } + switch { + case dogOk: + log.Printf("favorite_dog from arguments: %+v", dog) + dogPeople := make([]Person, 0) + for _, p := range people { + if p.FavoriteDog.Valid { + if p.FavoriteDog.String == dog.String { + dogPeople = append(dogPeople, p) + } + } + } + return dogPeople, nil + default: + return people, nil + } + }, + }, + }, + }), + }) + if err != nil { + log.Fatal(err) + } + query := ` +query { + people { + name + favorite_dog + } +}` + queryWithArgument := ` +query { + people(favorite_dog: "Yorkshire Terrier") { + name + favorite_dog + } +}` + r1 := graphql.Do(graphql.Params{ + Schema: *schema, + RequestString: query, + }) + r2 := graphql.Do(graphql.Params{ + Schema: *schema, + RequestString: queryWithArgument, + }) + if len(r1.Errors) > 0 { + log.Fatal(r1) + } + if len(r2.Errors) > 0 { + log.Fatal(r1) + } + b1, err := json.MarshalIndent(r1, "", " ") + b2, err := json.MarshalIndent(r2, "", " ") + if err != nil { + log.Fatal(err) + + } + fmt.Printf("\nQuery: %+v\n", string(query)) + fmt.Printf("\nResult: %+v\n", string(b1)) + fmt.Printf("\nQuery (with arguments): %+v\n", string(queryWithArgument)) + fmt.Printf("\nResult (with arguments): %+v\n", string(b2)) +} + +/* Output: +Query: +query { + people { + name + favorite_dog + } +} + +Result: { + "data": { + "people": [ + { + "favorite_dog": "Yorkshire Terrier", + "name": "Alice" + }, + { + "favorite_dog": "", + "name": "Bob" + }, + { + "favorite_dog": "French Bulldog", + "name": "Chris" + } + ] + } +} + +Query (with arguments): +query { + people(favorite_dog: "Yorkshire Terrier") { + name + favorite_dog + } +} + +Result (with arguments): { + "data": { + "people": [ + { + "favorite_dog": "Yorkshire Terrier", + "name": "Alice" + } + ] + } +} +*/ diff --git a/examples/todo/main.go b/examples/todo/main.go index b36b08d0..993f528d 100644 --- a/examples/todo/main.go +++ b/examples/todo/main.go @@ -207,7 +207,7 @@ 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().Get("query"), schema) + result := executeQuery(r.URL.Query().Get("query"), *schema) json.NewEncoder(w).Encode(result) }) // Serve static files diff --git a/executor_resolve_test.go b/executor_resolve_test.go index 7430cd86..ff45c0c8 100644 --- a/executor_resolve_test.go +++ b/executor_resolve_test.go @@ -20,7 +20,7 @@ func testSchema(t *testing.T, testField *graphql.Field) graphql.Schema { if err != nil { t.Fatalf("Invalid schema: %v", err) } - return schema + return *schema } func TestExecutesResolveFunction_DefaultFunctionAccessesProperties(t *testing.T) { diff --git a/executor_schema_test.go b/executor_schema_test.go index b39c4c3a..76f3b98e 100644 --- a/executor_schema_test.go +++ b/executor_schema_test.go @@ -302,7 +302,7 @@ func TestExecutesUsingAComplexSchema(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: blogSchema, + Schema: *blogSchema, AST: ast, } result := testutil.TestExecute(t, ep) diff --git a/executor_test.go b/executor_test.go index 856aadf3..113c9387 100644 --- a/executor_test.go +++ b/executor_test.go @@ -195,7 +195,7 @@ func TestExecutesArbitraryCode(t *testing.T) { } operationName := "Example" ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, Root: data, AST: astDoc, OperationName: operationName, @@ -285,7 +285,7 @@ func TestMergesParallelFragments(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -335,7 +335,7 @@ func TestCustomMapType(t *testing.T) { } result := testutil.TestExecute(t, graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, Root: data, AST: testutil.TestParse(t, query), }) @@ -388,7 +388,7 @@ func TestThreadsSourceCorrectly(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, Root: data, AST: ast, } @@ -444,7 +444,7 @@ func TestCorrectlyThreadsArguments(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -491,7 +491,7 @@ func TestThreadsRootValueContextCorrectly(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: map[string]interface{}{ "stringKey": "stringValue", @@ -540,7 +540,7 @@ func TestThreadsContextCorrectly(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Context: context.WithValue(context.Background(), "foo", "bar"), } @@ -614,7 +614,7 @@ func TestNullsOutErrorSubtrees(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, } @@ -659,7 +659,7 @@ func TestUsesTheInlineOperationIfNoOperationNameIsProvided(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, } @@ -704,7 +704,7 @@ func TestUsesTheOnlyOperationIfNoOperationNameIsProvided(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, } @@ -748,7 +748,7 @@ func TestUsesTheNamedOperationIfOperationNameIsProvided(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, OperationName: "OtherExample", @@ -795,7 +795,7 @@ func TestThrowsIfNoOperationIsProvided(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, } @@ -840,7 +840,7 @@ func TestThrowsIfNoOperationNameIsProvidedWithMultipleOperations(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, } @@ -886,7 +886,7 @@ func TestThrowsIfUnknownOperationNameIsProvided(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, OperationName: "UnknownExample", @@ -937,7 +937,7 @@ func TestThrowsIfOperationTypeIsUnsupported(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, OperationName: operation, } @@ -999,7 +999,7 @@ func TestUsesTheQuerySchemaForQueries(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, OperationName: "Q", @@ -1054,7 +1054,7 @@ func TestUsesTheMutationSchemaForMutations(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, OperationName: "M", @@ -1109,7 +1109,7 @@ func TestUsesTheSubscriptionSchemaForSubscriptions(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, OperationName: "S", @@ -1183,7 +1183,7 @@ func TestCorrectFieldOrderingDespiteExecutionOrder(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, } @@ -1249,7 +1249,7 @@ func TestAvoidsRecursion(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, OperationName: "Q", @@ -1301,7 +1301,7 @@ func TestDoesNotIncludeIllegalFieldsInOutput(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -1363,7 +1363,7 @@ func TestDoesNotIncludeArgumentsThatWereNotSet(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -1457,7 +1457,7 @@ func TestFailsWhenAnIsTypeOfCheckIsNotMet(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, } @@ -1503,7 +1503,7 @@ func TestFailsToExecuteQueryContainingATypeDefinition(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -1539,7 +1539,7 @@ func TestQuery_ExecutionAddsErrorsFromFieldResolveFn(t *testing.T) { } query := "{ a }" result := graphql.Do(graphql.Params{ - Schema: blogSchema, + Schema: *blogSchema, RequestString: query, }) if len(result.Errors) == 0 { @@ -1577,7 +1577,7 @@ func TestQuery_ExecutionDoesNotAddErrorsFromFieldResolveFn(t *testing.T) { } query := "{ b }" result := graphql.Do(graphql.Params{ - Schema: blogSchema, + Schema: *blogSchema, RequestString: query, }) if len(result.Errors) != 0 { @@ -1627,7 +1627,7 @@ func TestQuery_InputObjectUsesFieldDefaultValueFn(t *testing.T) { } query := `{ a(foo: {}) }` result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if len(result.Errors) != 0 { @@ -1681,7 +1681,7 @@ func TestMutation_ExecutionAddsErrorsFromFieldResolveFn(t *testing.T) { } query := "mutation _ { newFoo: foo(f:\"title\") }" result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if len(result.Errors) == 0 { @@ -1738,7 +1738,7 @@ func TestMutation_ExecutionDoesNotAddErrorsFromFieldResolveFn(t *testing.T) { } query := "mutation _ { newBar: bar(b:\"title\") }" result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if len(result.Errors) != 0 { @@ -1777,7 +1777,7 @@ func TestGraphqlTag(t *testing.T) { } query := "{ baz { fooBar } }" result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if len(result.Errors) != 0 { @@ -1829,7 +1829,7 @@ func TestFieldResolver(t *testing.T) { } query := "{ baz { fooBar }, bazPtr { fooBar } }" result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if len(result.Errors) != 0 { @@ -1893,7 +1893,7 @@ func TestContextDeadline(t *testing.T) { startTime := time.Now() result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: "{hello}", Context: ctx, }) @@ -1969,7 +1969,7 @@ func TestThunkResultsProcessedCorrectly(t *testing.T) { query := "{ foo { bar { bazA bazB } } }" result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if len(result.Errors) != 0 { @@ -2065,7 +2065,7 @@ func TestThunkErrorsAreHandledCorrectly(t *testing.T) { query := "{ foo { bar { bazA bazB bazC } } }" result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) @@ -2213,7 +2213,7 @@ func testErrors(t *testing.T, nameType graphql.Output, extensions map[string]int expectNoError(err) return graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: `{ hero { name diff --git a/extensions_test.go b/extensions_test.go index ea23f752..3ea521d4 100644 --- a/extensions_test.go +++ b/extensions_test.go @@ -35,7 +35,7 @@ func tinit(t *testing.T) graphql.Schema { if err != nil { t.Fatalf("Error in schema %v", err.Error()) } - return schema + return *schema } func TestExtensionInitPanic(t *testing.T) { diff --git a/graphql_test.go b/graphql_test.go index 8b06a7b1..37f853c7 100644 --- a/graphql_test.go +++ b/graphql_test.go @@ -143,7 +143,7 @@ func TestBasicGraphQLExample(t *testing.T) { } result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if len(result.Errors) > 0 { @@ -180,7 +180,7 @@ func TestThreadsContextFromParamsThrough(t *testing.T) { query := `{ value(key:"a") }` result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, Context: context.WithValue(context.TODO(), "a", "xyz"), }) @@ -213,7 +213,7 @@ func TestNewErrorChecksNilNodes(t *testing.T) { } query := `{graphql_is:great(sort:ByPopularity)}{stars}` result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if len(result.Errors) == 0 { @@ -257,7 +257,7 @@ func TestEmptyStringIsNotNull(t *testing.T) { query := `{ checkEmptyArg(arg:"") checkEmptyResult }` result := graphql.Do(graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if len(result.Errors) > 0 { diff --git a/introspection_test.go b/introspection_test.go index c0e62bf1..fe7738f7 100644 --- a/introspection_test.go +++ b/introspection_test.go @@ -825,7 +825,7 @@ func TestIntrospection_ExecutesAnIntrospectionQuery(t *testing.T) { }, } result := g(t, graphql.Params{ - Schema: emptySchema, + Schema: *emptySchema, RequestString: testutil.IntrospectionQuery, }) if !testutil.ContainSubset(result.Data.(map[string]interface{}), expectedDataSubSet) { @@ -937,7 +937,7 @@ func TestIntrospection_ExecutesAnInputObject(t *testing.T) { } result := g(t, graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if !testutil.ContainSubset(result.Data.(map[string]interface{}), expectedDataSubSet) { @@ -976,7 +976,7 @@ func TestIntrospection_SupportsThe__TypeRootField(t *testing.T) { }, } result := g(t, graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if !testutil.EqualResults(expected, result) { @@ -1035,7 +1035,7 @@ func TestIntrospection_IdentifiesDeprecatedFields(t *testing.T) { }, } result := g(t, graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if !testutil.ContainSubset(result.Data.(map[string]interface{}), expected.Data.(map[string]interface{})) { @@ -1104,7 +1104,7 @@ func TestIntrospection_RespectsTheIncludeDeprecatedParameterForFields(t *testing }, } result := g(t, graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if !testutil.ContainSubset(result.Data.(map[string]interface{}), expected.Data.(map[string]interface{})) { @@ -1179,7 +1179,7 @@ func TestIntrospection_IdentifiesDeprecatedEnumValues(t *testing.T) { }, } result := g(t, graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if !testutil.ContainSubset(result.Data.(map[string]interface{}), expected.Data.(map[string]interface{})) { @@ -1268,7 +1268,7 @@ func TestIntrospection_RespectsTheIncludeDeprecatedParameterForEnumValues(t *tes }, } result := g(t, graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if !testutil.ContainSubset(result.Data.(map[string]interface{}), expected.Data.(map[string]interface{})) { @@ -1310,7 +1310,7 @@ func TestIntrospection_FailsAsExpectedOnThe__TypeRootFieldWithoutAnArg(t *testin }, } result := g(t, graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if !testutil.EqualResults(expected, result) { @@ -1383,7 +1383,7 @@ func TestIntrospection_ExposesDescriptionsOnTypesAndFields(t *testing.T) { }, } result := g(t, graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if !testutil.ContainSubset(result.Data.(map[string]interface{}), expected.Data.(map[string]interface{})) { @@ -1461,7 +1461,7 @@ func TestIntrospection_ExposesDescriptionsOnEnums(t *testing.T) { }, } result := g(t, graphql.Params{ - Schema: schema, + Schema: *schema, RequestString: query, }) if !testutil.ContainSubset(result.Data.(map[string]interface{}), expected.Data.(map[string]interface{})) { diff --git a/lists_test.go b/lists_test.go index 9c098ea3..60e456be 100644 --- a/lists_test.go +++ b/lists_test.go @@ -44,7 +44,7 @@ func checkList(t *testing.T, testType graphql.Type, testData interface{}, expect // execute ep := graphql.ExecuteParams{ - Schema: schema, + Schema: *schema, AST: ast, Root: data, } @@ -902,7 +902,7 @@ func TestLists_ValueMayBeNilPointer(t *testing.T) { }, } result := g(t, graphql.Params{ - Schema: listTestSchema, + Schema: *listTestSchema, RequestString: query, }) if !reflect.DeepEqual(expected, result) { diff --git a/mutations_test.go b/mutations_test.go index a97dda52..dee9b55a 100644 --- a/mutations_test.go +++ b/mutations_test.go @@ -164,7 +164,7 @@ func TestMutations_ExecutionOrdering_EvaluatesMutationsSerially(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: mutationsTestSchema, + Schema: *mutationsTestSchema, AST: ast, Root: root, } @@ -237,7 +237,7 @@ func TestMutations_EvaluatesMutationsCorrectlyInThePresenceOfAFailedMutation(t * // execute ep := graphql.ExecuteParams{ - Schema: mutationsTestSchema, + Schema: *mutationsTestSchema, AST: ast, Root: root, } diff --git a/nonnull_test.go b/nonnull_test.go index b5a6683a..021b6465 100644 --- a/nonnull_test.go +++ b/nonnull_test.go @@ -138,7 +138,7 @@ func TestNonNull_NullsANullableFieldThatThrowsSynchronously(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: throwingData, } @@ -176,7 +176,7 @@ func TestNonNull_NullsANullableFieldThatThrowsInAPromise(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: throwingData, } @@ -217,7 +217,7 @@ func TestNonNull_NullsASynchronouslyReturnedObjectThatContainsANullableFieldThat // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: throwingData, } @@ -258,7 +258,7 @@ func TestNonNull_NullsASynchronouslyReturnedObjectThatContainsANonNullableFieldT // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: throwingData, } @@ -299,7 +299,7 @@ func TestNonNull_NullsAnObjectReturnedInAPromiseThatContainsANonNullableFieldTha // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: throwingData, } @@ -340,7 +340,7 @@ func TestNonNull_NullsAnObjectReturnedInAPromiseThatContainsANonNullableFieldTha // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: throwingData, } @@ -522,7 +522,7 @@ func TestNonNull_NullsAComplexTreeOfNullableFieldsThatThrow(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: throwingData, } @@ -637,7 +637,7 @@ func TestNonNull_NullsTheFirstNullableObjectAfterAFieldThrowsInALongChainOfField // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: throwingData, } @@ -665,7 +665,7 @@ func TestNonNull_NullsANullableFieldThatSynchronouslyReturnsNull(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: nullingData, } @@ -690,7 +690,7 @@ func TestNonNull_NullsANullableFieldThatSynchronouslyReturnsNullInAPromise(t *te // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: nullingData, } @@ -729,7 +729,7 @@ func TestNonNull_NullsASynchronouslyReturnedObjectThatContainsANonNullableFieldT // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: nullingData, } @@ -768,7 +768,7 @@ func TestNonNull_NullsASynchronouslyReturnedObjectThatContainsANonNullableFieldT // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: nullingData, } @@ -808,7 +808,7 @@ func TestNonNull_NullsAnObjectReturnedInAPromiseThatContainsANonNullableFieldTha // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: nullingData, } @@ -847,7 +847,7 @@ func TestNonNull_NullsAnObjectReturnedInAPromiseThatContainsANonNullableFieldTha // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: nullingData, } @@ -918,7 +918,7 @@ func TestNonNull_NullsAComplexTreeOfNullableFieldsThatReturnNull(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: nullingData, } @@ -1031,7 +1031,7 @@ func TestNonNull_NullsTheFirstNullableObjectAfterAFieldReturnsNullInALongChainOf // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: nullingData, } @@ -1066,7 +1066,7 @@ func TestNonNull_NullsTheTopLevelIfSyncNonNullableFieldThrows(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: throwingData, } @@ -1098,7 +1098,7 @@ func TestNonNull_NullsTheTopLevelIfSyncNonNullableFieldErrors(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: throwingData, } @@ -1130,7 +1130,7 @@ func TestNonNull_NullsTheTopLevelIfSyncNonNullableFieldReturnsNull(t *testing.T) // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: nullingData, } @@ -1162,7 +1162,7 @@ func TestNonNull_NullsTheTopLevelIfSyncNonNullableFieldResolvesNull(t *testing.T // execute ep := graphql.ExecuteParams{ - Schema: nonNullTestSchema, + Schema: *nonNullTestSchema, AST: ast, Root: nullingData, } diff --git a/rules_overlapping_fields_can_be_merged_test.go b/rules_overlapping_fields_can_be_merged_test.go index bf36bae8..dff6a2a8 100644 --- a/rules_overlapping_fields_can_be_merged_test.go +++ b/rules_overlapping_fields_can_be_merged_test.go @@ -400,7 +400,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_IgnoresUnknownFragments(t *testin var someBoxInterface *graphql.Interface var stringBoxObject *graphql.Object var intBoxObject *graphql.Object -var schema graphql.Schema +var schema *graphql.Schema func init() { someBoxInterface = graphql.NewInterface(graphql.InterfaceConfig{ @@ -587,7 +587,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Conf // type IntBox and the interface type NonNullStringBox1. While that // condition does not exist in the current schema, the schema could // expand in the future to allow this. Thus it is invalid. - testutil.ExpectFailsRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectFailsRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { someBox { ...on IntBox { @@ -609,7 +609,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Comp // In this case `deepBox` returns `SomeBox` in the first usage, and // `StringBox` in the second usage. These return types are not the same! // however this is valid because the return *shapes* are compatible. - testutil.ExpectPassesRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectPassesRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { someBox { ... on SomeBox { @@ -627,7 +627,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Comp `) } func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_DisallowsDifferingReturnTypesDespiteNoOverlap(t *testing.T) { - testutil.ExpectFailsRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectFailsRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { someBox { ... on IntBox { @@ -646,7 +646,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Disa }) } func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_ReportsCorrectlyWhenANonExclusiveFollosAnExclusive(t *testing.T) { - testutil.ExpectFailsRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectFailsRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { someBox { ... on IntBox { @@ -700,7 +700,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Repo }) } func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_DisallowsDifferingReturnTypeNullabilityDespiteNoOverlap(t *testing.T) { - testutil.ExpectFailsRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectFailsRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { someBox { ... on NonNullStringBox1 { @@ -719,7 +719,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Disa }) } func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_DisallowsDifferingReturnTypeListDespiteNoOverlap(t *testing.T) { - testutil.ExpectFailsRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectFailsRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { someBox { ... on IntBox { @@ -741,7 +741,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Disa 10, 15), }) - testutil.ExpectFailsRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectFailsRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { someBox { ... on IntBox { @@ -764,7 +764,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Disa }) } func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_DisallowsDifferingSubfields(t *testing.T) { - testutil.ExpectFailsRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectFailsRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { someBox { ... on IntBox { @@ -788,7 +788,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Disa }) } func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_DisallowsDifferingDeepReturnTypesDespiteNoOverlap(t *testing.T) { - testutil.ExpectFailsRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectFailsRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { someBox { ... on IntBox { @@ -813,7 +813,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Disa }) } func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_AllowsNonConflictingOverlappingTypes(t *testing.T) { - testutil.ExpectPassesRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectPassesRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { someBox { ... on IntBox { @@ -827,7 +827,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Allo `) } func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_SameWrappedScalarReturnTypes(t *testing.T) { - testutil.ExpectPassesRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectPassesRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { someBox { ...on NonNullStringBox1 { @@ -841,7 +841,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Same `) } func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_AllowsInlineTypelessFragments(t *testing.T) { - testutil.ExpectPassesRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectPassesRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { a ... { @@ -851,7 +851,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Allo `) } func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_ComparesDeepTypesIncludingList(t *testing.T) { - testutil.ExpectFailsRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectFailsRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { connection { ...edgeID @@ -883,7 +883,7 @@ func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_Comp }) } func TestValidate_OverlappingFieldsCanBeMerged_ReturnTypesMustBeUnambiguous_IgnoresUnknownTypes(t *testing.T) { - testutil.ExpectPassesRuleWithSchema(t, &schema, graphql.OverlappingFieldsCanBeMergedRule, ` + testutil.ExpectPassesRuleWithSchema(t, schema, graphql.OverlappingFieldsCanBeMergedRule, ` { someBox { ...on UnknownType { diff --git a/schema.go b/schema.go index 53971645..3b6e2c14 100644 --- a/schema.go +++ b/schema.go @@ -47,23 +47,23 @@ type Schema struct { extensions []Extension } -func NewSchema(config SchemaConfig) (Schema, error) { +func NewSchema(config SchemaConfig) (*Schema, error) { var err error - schema := Schema{} - if err = invariant(config.Query != nil, "Schema query must be Object Type but got: nil."); err != nil { - return schema, err + return nil, err } // if schema config contains error at creation time, return those errors if config.Query != nil && config.Query.err != nil { - return schema, config.Query.err + return nil, config.Query.err } if config.Mutation != nil && config.Mutation.err != nil { - return schema, config.Mutation.err + return nil, config.Mutation.err } + schema := Schema{} + schema.queryType = config.Query schema.mutationType = config.Mutation schema.subscriptionType = config.Subscription @@ -76,7 +76,7 @@ func NewSchema(config SchemaConfig) (Schema, error) { // Ensure directive definitions are error-free for _, dir := range schema.directives { if dir.err != nil { - return schema, dir.err + return nil, dir.err } } @@ -103,10 +103,10 @@ func NewSchema(config SchemaConfig) (Schema, error) { for _, ttype := range initialTypes { if ttype.Error() != nil { - return schema, ttype.Error() + return nil, ttype.Error() } if typeMap, err = typeMapReducer(&schema, typeMap, ttype); err != nil { - return schema, err + return nil, err } } @@ -135,7 +135,7 @@ func NewSchema(config SchemaConfig) (Schema, error) { for _, iface := range ttype.Interfaces() { err := assertObjectImplementsInterface(&schema, ttype, iface) if err != nil { - return schema, err + return nil, err } } } @@ -146,7 +146,7 @@ func NewSchema(config SchemaConfig) (Schema, error) { schema.extensions = config.Extensions } - return schema, nil + return &schema, nil } //Added Check implementation of interfaces at runtime.. diff --git a/testutil/rules_test_harness.go b/testutil/rules_test_harness.go index 384f447e..40ef7297 100644 --- a/testutil/rules_test_harness.go +++ b/testutil/rules_test_harness.go @@ -542,9 +542,9 @@ func init() { if err != nil { panic(err) } - TestSchema = &schema - + TestSchema = schema } + func expectValidRule(t *testing.T, schema *graphql.Schema, rules []graphql.ValidationRuleFn, queryString string) { source := source.NewSource(&source.Source{ Body: []byte(queryString), diff --git a/testutil/testutil.go b/testutil/testutil.go index 0d905542..c77be760 100644 --- a/testutil/testutil.go +++ b/testutil/testutil.go @@ -322,9 +322,11 @@ func init() { }, }, }) - StarWarsSchema, _ = graphql.NewSchema(graphql.SchemaConfig{ + schema, _ := graphql.NewSchema(graphql.SchemaConfig{ Query: queryType, }) + + StarWarsSchema = *schema } func GetHuman(id int) StarWarsChar { diff --git a/type_comparators_internal_test.go b/type_comparators_internal_test.go index 995166ef..ea4b1e67 100644 --- a/type_comparators_internal_test.go +++ b/type_comparators_internal_test.go @@ -49,7 +49,7 @@ func testSchemaForIsTypeSubTypeOfTest(t *testing.T, fields Fields) *Schema { if err != nil { t.Fatalf("Invalid schema: %v", err) } - return &schema + return schema } func TestIsTypeSubTypeOf_SameReferenceIsSubtype(t *testing.T) { diff --git a/union_interface_test.go b/union_interface_test.go index 8f850d60..7be3832f 100644 --- a/union_interface_test.go +++ b/union_interface_test.go @@ -201,7 +201,7 @@ func TestUnionIntersectionTypes_CanIntrospectOnUnionAndIntersectionTypes(t *test // execute ep := graphql.ExecuteParams{ - Schema: unionInterfaceTestSchema, + Schema: *unionInterfaceTestSchema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -249,7 +249,7 @@ func TestUnionIntersectionTypes_ExecutesUsingUnionTypes(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: unionInterfaceTestSchema, + Schema: *unionInterfaceTestSchema, AST: ast, Root: john, } @@ -303,7 +303,7 @@ func TestUnionIntersectionTypes_ExecutesUnionTypesWithInlineFragments(t *testing // execute ep := graphql.ExecuteParams{ - Schema: unionInterfaceTestSchema, + Schema: *unionInterfaceTestSchema, AST: ast, Root: john, } @@ -352,7 +352,7 @@ func TestUnionIntersectionTypes_ExecutesUsingInterfaceTypes(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: unionInterfaceTestSchema, + Schema: *unionInterfaceTestSchema, AST: ast, Root: john, } @@ -405,7 +405,7 @@ func TestUnionIntersectionTypes_ExecutesInterfaceTypesWithInlineFragments(t *tes // execute ep := graphql.ExecuteParams{ - Schema: unionInterfaceTestSchema, + Schema: *unionInterfaceTestSchema, AST: ast, Root: john, } @@ -485,7 +485,7 @@ func TestUnionIntersectionTypes_AllowsFragmentConditionsToBeAbstractTypes(t *tes // execute ep := graphql.ExecuteParams{ - Schema: unionInterfaceTestSchema, + Schema: *unionInterfaceTestSchema, AST: ast, Root: john, } @@ -565,7 +565,7 @@ func TestUnionIntersectionTypes_GetsExecutionInfoInResolver(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: schema2, + Schema: *schema2, AST: ast, Root: john2, Context: ctx, @@ -581,7 +581,7 @@ func TestUnionIntersectionTypes_GetsExecutionInfoInResolver(t *testing.T) { if !reflect.DeepEqual("John", encounteredRootValue) { t.Fatalf("Unexpected result, Diff: %v", testutil.Diff("John", encounteredRootValue)) } - if !reflect.DeepEqual(schema2, encounteredSchema) { + if !reflect.DeepEqual(*schema2, encounteredSchema) { t.Fatalf("Unexpected result, Diff: %v", testutil.Diff(schema2, encounteredSchema)) } } @@ -632,7 +632,7 @@ func TestUnionIntersectionTypes_ValueMayBeNilPointer(t *testing.T) { }}, } result := g(t, graphql.Params{ - Schema: unionInterfaceTestSchema, + Schema: *unionInterfaceTestSchema, RequestString: query, }) if !reflect.DeepEqual(expected, result) { diff --git a/util_test.go b/util_test.go index 6fb6e900..6bcc3ddc 100644 --- a/util_test.go +++ b/util_test.go @@ -91,7 +91,7 @@ func TestBindFields(t *testing.T) { } } ` - params := graphql.Params{Schema: schema, RequestString: query} + params := graphql.Params{Schema: *schema, RequestString: query} r := graphql.Do(params) if len(r.Errors) > 0 { log.Fatalf("failed to execute graphql operation, errors: %+v", r.Errors) @@ -152,7 +152,7 @@ func TestBindArg(t *testing.T) { } } ` - params := graphql.Params{Schema: schema, RequestString: query} + params := graphql.Params{Schema: *schema, RequestString: query} r := graphql.Do(params) if len(r.Errors) > 0 { log.Fatalf("failed to execute graphql operation, errors: %+v", r.Errors) diff --git a/validation_test.go b/validation_test.go index 6c8fc521..f0c63dff 100644 --- a/validation_test.go +++ b/validation_test.go @@ -103,7 +103,7 @@ var inputTypes = withModifiers([]graphql.Type{ someInputObject, }) -func schemaWithFieldType(ttype graphql.Output) (graphql.Schema, error) { +func schemaWithFieldType(ttype graphql.Output) (*graphql.Schema, error) { return graphql.NewSchema(graphql.SchemaConfig{ Query: graphql.NewObject(graphql.ObjectConfig{ Name: "Query", @@ -116,7 +116,7 @@ func schemaWithFieldType(ttype graphql.Output) (graphql.Schema, error) { Types: []graphql.Type{ttype}, }) } -func schemaWithInputObject(ttype graphql.Input) (graphql.Schema, error) { +func schemaWithInputObject(ttype graphql.Input) (*graphql.Schema, error) { return graphql.NewSchema(graphql.SchemaConfig{ Query: graphql.NewObject(graphql.ObjectConfig{ Name: "Query", @@ -133,7 +133,7 @@ func schemaWithInputObject(ttype graphql.Input) (graphql.Schema, error) { }), }) } -func schemaWithObjectFieldOfType(fieldType graphql.Input) (graphql.Schema, error) { +func schemaWithObjectFieldOfType(fieldType graphql.Input) (*graphql.Schema, error) { badObjectType := graphql.NewObject(graphql.ObjectConfig{ Name: "BadObject", @@ -154,7 +154,7 @@ func schemaWithObjectFieldOfType(fieldType graphql.Input) (graphql.Schema, error }), }) } -func schemaWithObjectImplementingType(implementedType *graphql.Interface) (graphql.Schema, error) { +func schemaWithObjectImplementingType(implementedType *graphql.Interface) (*graphql.Schema, error) { badObjectType := graphql.NewObject(graphql.ObjectConfig{ Name: "BadObject", @@ -177,7 +177,7 @@ func schemaWithObjectImplementingType(implementedType *graphql.Interface) (graph Types: []graphql.Type{badObjectType}, }) } -func schemaWithUnionOfType(ttype *graphql.Object) (graphql.Schema, error) { +func schemaWithUnionOfType(ttype *graphql.Object) (*graphql.Schema, error) { badObjectType := graphql.NewUnion(graphql.UnionConfig{ Name: "BadUnion", @@ -197,7 +197,7 @@ func schemaWithUnionOfType(ttype *graphql.Object) (graphql.Schema, error) { }), }) } -func schemaWithInterfaceFieldOfType(ttype graphql.Type) (graphql.Schema, error) { +func schemaWithInterfaceFieldOfType(ttype graphql.Type) (*graphql.Schema, error) { badInterfaceType := graphql.NewInterface(graphql.InterfaceConfig{ Name: "BadInterface", @@ -218,7 +218,7 @@ func schemaWithInterfaceFieldOfType(ttype graphql.Type) (graphql.Schema, error) }), }) } -func schemaWithArgOfType(ttype graphql.Type) (graphql.Schema, error) { +func schemaWithArgOfType(ttype graphql.Type) (*graphql.Schema, error) { badObject := graphql.NewObject(graphql.ObjectConfig{ Name: "BadObject", @@ -244,7 +244,7 @@ func schemaWithArgOfType(ttype graphql.Type) (graphql.Schema, error) { }), }) } -func schemaWithInputFieldOfType(ttype graphql.Type) (graphql.Schema, error) { +func schemaWithInputFieldOfType(ttype graphql.Type) (*graphql.Schema, error) { badInputObject := graphql.NewInputObject(graphql.InputObjectConfig{ Name: "BadInputObject", diff --git a/variables_test.go b/variables_test.go index 9dc430df..320d5de7 100644 --- a/variables_test.go +++ b/variables_test.go @@ -186,7 +186,7 @@ func TestVariables_ObjectsAndNullability_UsingInlineStructs_ExecutesWithComplexI // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -213,7 +213,7 @@ func TestVariables_ObjectsAndNullability_UsingInlineStructs_ProperlyParsesSingle // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -240,7 +240,7 @@ func TestVariables_ObjectsAndNullability_UsingInlineStructs_DoesNotUseIncorrectV // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -267,7 +267,7 @@ func TestVariables_ObjectsAndNullability_UsingInlineStructs_ProperlyRunsParseLit // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -306,7 +306,7 @@ func TestVariables_ObjectsAndNullability_UsingVariables_ExecutesWithComplexInput // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -336,7 +336,7 @@ func TestVariables_ObjectsAndNullability_UsingVariables_UsesDefaultValueWhenNotP // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: withDefaultsAST, } result := testutil.TestExecute(t, ep) @@ -365,7 +365,7 @@ func TestVariables_ObjectsAndNullability_UsingVariables_ProperlyParsesSingleValu // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -394,7 +394,7 @@ func TestVariables_ObjectsAndNullability_UsingVariables_ExecutesWithComplexScala // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -433,7 +433,7 @@ func TestVariables_ObjectsAndNullability_UsingVariables_ErrorsOnNullForNestedNon // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -464,7 +464,7 @@ func TestVariables_ObjectsAndNullability_UsingVariables_ErrorsOnIncorrectType(t // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -499,7 +499,7 @@ func TestVariables_ObjectsAndNullability_UsingVariables_ErrorsOnOmissionOfNested // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -541,7 +541,7 @@ func TestVariables_ObjectsAndNullability_UsingVariables_ErrorsOnDeepNestedErrors // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: nestedAST, Args: params, } @@ -578,7 +578,7 @@ func TestVariables_ObjectsAndNullability_UsingVariables_ErrorsOnAdditionOfUnknow // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -604,7 +604,7 @@ func TestVariables_NullableScalars_AllowsNullableInputsToBeOmitted(t *testing.T) // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -631,7 +631,7 @@ func TestVariables_NullableScalars_AllowsNullableInputsToBeOmittedInAVariable(t // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -658,7 +658,7 @@ func TestVariables_NullableScalars_AllowsNullableInputsToBeOmittedInAnUnlistedVa // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -688,7 +688,7 @@ func TestVariables_NullableScalars_AllowsNullableInputsToBeSetToNullInAVariable( // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -719,7 +719,7 @@ func TestVariables_NullableScalars_AllowsNullableInputsToBeSetToAValueInAVariabl // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -747,7 +747,7 @@ func TestVariables_NullableScalars_AllowsNullableInputsToBeSetToAValueDirectly(t // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -785,7 +785,7 @@ func TestVariables_NonNullableScalars_DoesNotAllowNonNullableInputsToBeOmittedIn // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -821,7 +821,7 @@ func TestVariables_NonNullableScalars_DoesNotAllowNonNullableInputsToBeSetToNull // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -850,7 +850,7 @@ func TestVariables_NonNullableScalars_AllowsNonNullableInputsToBeSetToAValueInAV // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -883,7 +883,7 @@ func TestVariables_NonNullableScalars_AllowsNonNullableInputsToBeSetToAValueDire // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -916,7 +916,7 @@ func TestVariables_NonNullableScalars_PassesAlongNullForNonNullableInputsIfExpli // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -948,7 +948,7 @@ func TestVariables_ListsAndNullability_AllowsListsToBeNull(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -979,7 +979,7 @@ func TestVariables_ListsAndNullability_AllowsListsToContainValues(t *testing.T) // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -1010,7 +1010,7 @@ func TestVariables_ListsAndNullability_AllowsListsToContainNull(t *testing.T) { // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -1045,7 +1045,7 @@ func TestVariables_ListsAndNullability_DoesNotAllowNonNullListsToBeNull(t *testi // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -1071,7 +1071,7 @@ func TestVariables_ListsAndNullability_AllowsNonNullListsToContainValues(t *test // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -1101,7 +1101,7 @@ func TestVariables_ListsAndNullability_AllowsNonNullListsToContainNull(t *testin // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -1131,7 +1131,7 @@ func TestVariables_ListsAndNullability_AllowsListsOfNonNullsToBeNull(t *testing. // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -1161,7 +1161,7 @@ func TestVariables_ListsAndNullability_AllowsListsOfNonNullsToContainValues(t *t // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -1201,7 +1201,7 @@ func TestVariables_ListsAndNullability_DoesNotAllowListOfNonNullsToContainNull(t // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -1236,7 +1236,7 @@ func TestVariables_ListsAndNullability_DoesNotAllowNonNullListOfNonNullsToBeNull // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -1263,7 +1263,7 @@ func TestVariables_ListsAndNullability_AllowsNonNullListsOfNonNulsToContainValue // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -1303,7 +1303,7 @@ func TestVariables_ListsAndNullability_DoesNotAllowNonNullListOfNonNullsToContai // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -1340,7 +1340,7 @@ func TestVariables_ListsAndNullability_DoesNotAllowInvalidTypesToBeUsedAsValues( // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -1378,7 +1378,7 @@ func TestVariables_ListsAndNullability_DoesNotAllowUnknownTypesToBeUsedAsValues( // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, Args: params, } @@ -1403,7 +1403,7 @@ func TestVariables_UsesArgumentDefaultValues_WhenNoArgumentProvided(t *testing.T // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -1429,7 +1429,7 @@ func TestVariables_UsesArgumentDefaultValues_WhenNullableVariableProvided(t *tes // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, } result := testutil.TestExecute(t, ep) @@ -1455,7 +1455,7 @@ func TestVariables_UsesArgumentDefaultValues_WhenArgumentProvidedCannotBeParsed( // execute ep := graphql.ExecuteParams{ - Schema: variablesTestSchema, + Schema: *variablesTestSchema, AST: ast, } result := testutil.TestExecute(t, ep)