Skip to content

Commit 26c8e5d

Browse files
committed
handler: removes graphql-go/relay dependency
Removes unneeded dependency, also we can keep the tests simpler using graphql-go/graphql/testutil.StarWarsSchema
1 parent 07e3dd4 commit 26c8e5d

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

handler_test.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/graphql-go/graphql"
1414
"github.com/graphql-go/graphql/testutil"
1515
"github.com/graphql-go/handler"
16-
"github.com/graphql-go/relay/examples/starwars" // TODO: remove this dependency
1716
"golang.org/x/net/context"
1817
)
1918

@@ -53,7 +52,9 @@ func TestContextPropagated(t *testing.T) {
5352
},
5453
},
5554
})
56-
myNameSchema, err := graphql.NewSchema(graphql.SchemaConfig{myNameQuery, nil})
55+
myNameSchema, err := graphql.NewSchema(graphql.SchemaConfig{
56+
Query: myNameQuery,
57+
})
5758
if err != nil {
5859
t.Fatal(err)
5960
}
@@ -86,17 +87,16 @@ func TestContextPropagated(t *testing.T) {
8687
func TestHandler_BasicQuery_Pretty(t *testing.T) {
8788
expected := &graphql.Result{
8889
Data: map[string]interface{}{
89-
"rebels": map[string]interface{}{
90-
"id": "RmFjdGlvbjox",
91-
"name": "Alliance to Restore the Republic",
90+
"hero": map[string]interface{}{
91+
"name": "R2-D2",
9292
},
9393
},
9494
}
95-
queryString := `query=query RebelsShipsQuery { rebels { id, name } }`
95+
queryString := `query=query HeroNameQuery { hero { name } }`
9696
req, _ := http.NewRequest("GET", fmt.Sprintf("/graphql?%v", queryString), nil)
9797

9898
h := handler.New(&handler.Config{
99-
Schema: &starwars.Schema,
99+
Schema: &testutil.StarWarsSchema,
100100
Pretty: true,
101101
})
102102
result, resp := executeTest(t, h, req)
@@ -111,17 +111,16 @@ func TestHandler_BasicQuery_Pretty(t *testing.T) {
111111
func TestHandler_BasicQuery_Ugly(t *testing.T) {
112112
expected := &graphql.Result{
113113
Data: map[string]interface{}{
114-
"rebels": map[string]interface{}{
115-
"id": "RmFjdGlvbjox",
116-
"name": "Alliance to Restore the Republic",
114+
"hero": map[string]interface{}{
115+
"name": "R2-D2",
117116
},
118117
},
119118
}
120-
queryString := `query=query RebelsShipsQuery { rebels { id, name } }`
119+
queryString := `query=query HeroNameQuery { hero { name } }`
121120
req, _ := http.NewRequest("GET", fmt.Sprintf("/graphql?%v", queryString), nil)
122121

123122
h := handler.New(&handler.Config{
124-
Schema: &starwars.Schema,
123+
Schema: &testutil.StarWarsSchema,
125124
Pretty: false,
126125
})
127126
result, resp := executeTest(t, h, req)

0 commit comments

Comments
 (0)