Skip to content

Commit 51495a7

Browse files
return nil schema on error
1 parent 02caa89 commit 51495a7

33 files changed

+442
-440
lines changed

abstract_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForInterface(t *testing.T) {
147147
}
148148

149149
result := graphql.Do(graphql.Params{
150-
Schema: schema,
150+
Schema: *schema,
151151
RequestString: query,
152152
})
153153
if len(result.Errors) != 0 {
@@ -284,7 +284,7 @@ func TestAppendTypeUsedToAddRuntimeCustomScalarTypeForInterface(t *testing.T) {
284284
}
285285

286286
result := graphql.Do(graphql.Params{
287-
Schema: schema,
287+
Schema: *schema,
288288
RequestString: query,
289289
})
290290
if len(result.Errors) != 0 {
@@ -384,7 +384,7 @@ func TestIsTypeOfUsedToResolveRuntimeTypeForUnion(t *testing.T) {
384384
}
385385

386386
result := graphql.Do(graphql.Params{
387-
Schema: schema,
387+
Schema: *schema,
388388
RequestString: query,
389389
})
390390
if len(result.Errors) != 0 {
@@ -523,7 +523,7 @@ func TestResolveTypeOnInterfaceYieldsUsefulError(t *testing.T) {
523523
}
524524

525525
result := graphql.Do(graphql.Params{
526-
Schema: schema,
526+
Schema: *schema,
527527
RequestString: query,
528528
})
529529
if !testutil.EqualResults(expected, result) {
@@ -647,7 +647,7 @@ func TestResolveTypeOnUnionYieldsUsefulError(t *testing.T) {
647647
}
648648

649649
result := graphql.Do(graphql.Params{
650-
Schema: schema,
650+
Schema: *schema,
651651
RequestString: query,
652652
})
653653
if !testutil.EqualResults(expected, result) {

benchutil/list_schema.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func ListSchemaWithXItems(x int) graphql.Schema {
8080
Query: queryType,
8181
})
8282

83-
return colorSchema
83+
return *colorSchema
8484
}
8585

8686
var colors []color

benchutil/wide_schema.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func WideSchemaWithXFieldsAndYItems(x int, y int) graphql.Schema {
3333
Query: queryType,
3434
})
3535

36-
return wideSchema
36+
return *wideSchema
3737
}
3838

3939
func generateXWideFields(x int) graphql.Fields {

directives_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var directivesTestData map[string]interface{} = map[string]interface{}{
3131
func executeDirectivesTestQuery(t *testing.T, doc string) *graphql.Result {
3232
ast := testutil.TestParse(t, doc)
3333
ep := graphql.ExecuteParams{
34-
Schema: directivesTestSchema,
34+
Schema: *directivesTestSchema,
3535
AST: ast,
3636
Root: directivesTestData,
3737
}

enum_type_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ var enumTypeTestSchema, _ = graphql.NewSchema(graphql.SchemaConfig{
123123

124124
func executeEnumTypeTest(t *testing.T, query string) *graphql.Result {
125125
result := g(t, graphql.Params{
126-
Schema: enumTypeTestSchema,
126+
Schema: *enumTypeTestSchema,
127127
RequestString: query,
128128
})
129129
return result
130130
}
131131
func executeEnumTypeTestWithParams(t *testing.T, query string, params map[string]interface{}) *graphql.Result {
132132
result := g(t, graphql.Params{
133-
Schema: enumTypeTestSchema,
133+
Schema: *enumTypeTestSchema,
134134
RequestString: query,
135135
VariableValues: params,
136136
})
@@ -414,7 +414,7 @@ func TestTypeSystem_EnumValues_EnumValueMayBePointer(t *testing.T) {
414414
"color": "GREEN",
415415
"foo": 1}}}
416416
result := g(t, graphql.Params{
417-
Schema: enumTypeTestSchema,
417+
Schema: *enumTypeTestSchema,
418418
RequestString: query,
419419
})
420420
if !reflect.DeepEqual(expected, result) {
@@ -453,7 +453,7 @@ func TestTypeSystem_EnumValues_EnumValueMayBeNilPointer(t *testing.T) {
453453
}},
454454
}
455455
result := g(t, graphql.Params{
456-
Schema: enumTypeTestSchema,
456+
Schema: *enumTypeTestSchema,
457457
RequestString: query,
458458
})
459459
if !reflect.DeepEqual(expected, result) {

examples/concurrent-resolvers/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func main() {
8686
`
8787
result := graphql.Do(graphql.Params{
8888
RequestString: query,
89-
Schema: schema,
89+
Schema: *schema,
9090
})
9191
b, err := json.Marshal(result)
9292
if err != nil {

examples/context/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ func init() {
7070
if err != nil {
7171
log.Fatalf("failed to create schema, error: %v", err)
7272
}
73-
Schema = s
73+
Schema = *s
7474
}

examples/crud/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func executeQuery(query string, schema graphql.Schema) *graphql.Result {
226226

227227
func main() {
228228
http.HandleFunc("/product", func(w http.ResponseWriter, r *http.Request) {
229-
result := executeQuery(r.URL.Query().Get("query"), schema)
229+
result := executeQuery(r.URL.Query().Get("query"), *schema)
230230
json.NewEncoder(w).Encode(result)
231231
})
232232

examples/custom-scalar-type/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func main() {
124124
`
125125
*/
126126
result := graphql.Do(graphql.Params{
127-
Schema: schema,
127+
Schema: *schema,
128128
RequestString: query,
129129
VariableValues: map[string]interface{}{
130130
"id": "5b42ba57289",

examples/hello-world/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func main() {
3131
hello
3232
}
3333
`
34-
params := graphql.Params{Schema: schema, RequestString: query}
34+
params := graphql.Params{Schema: *schema, RequestString: query}
3535
r := graphql.Do(params)
3636
if len(r.Errors) > 0 {
3737
log.Fatalf("failed to execute graphql operation, errors: %+v", r.Errors)

examples/http/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func main() {
8888
_ = importJSONDataFromFile("data.json", &data)
8989

9090
http.HandleFunc("/graphql", func(w http.ResponseWriter, r *http.Request) {
91-
result := executeQuery(r.URL.Query().Get("query"), schema)
91+
result := executeQuery(r.URL.Query().Get("query"), *schema)
9292
json.NewEncoder(w).Encode(result)
9393
})
9494

examples/httpdynamic/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
/* Shared data variables to allow dynamic reloads
1818
/*****************************************************************************/
1919

20-
var schema graphql.Schema
20+
var schema *graphql.Schema
2121

2222
const jsonDataFile = "data.json"
2323

@@ -127,7 +127,7 @@ func main() {
127127
}
128128

129129
http.HandleFunc("/graphql", func(w http.ResponseWriter, r *http.Request) {
130-
result := executeQuery(r.URL.Query().Get("query"), schema)
130+
result := executeQuery(r.URL.Query().Get("query"), *schema)
131131
json.NewEncoder(w).Encode(result)
132132
})
133133

examples/modify-context/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func main() {
6565
Context: ctx,
6666
RequestString: "{ users { id } }",
6767
RootObject: rootObject,
68-
Schema: schema,
68+
Schema: *schema,
6969
})
7070
b, err := json.Marshal(result)
7171
if err != nil {

0 commit comments

Comments
 (0)