@@ -13,8 +13,7 @@ import (
13
13
"github.com/graphql-go/graphql"
14
14
"github.com/graphql-go/graphql/testutil"
15
15
"github.com/graphql-go/handler"
16
- "github.com/graphql-go/relay/examples/starwars" // TODO: remove this dependency
17
- "golang.org/x/net/context"
16
+ "context"
18
17
)
19
18
20
19
func decodeResponse (t * testing.T , recorder * httptest.ResponseRecorder ) * graphql.Result {
@@ -53,7 +52,9 @@ func TestContextPropagated(t *testing.T) {
53
52
},
54
53
},
55
54
})
56
- myNameSchema , err := graphql .NewSchema (graphql.SchemaConfig {myNameQuery , nil })
55
+ myNameSchema , err := graphql .NewSchema (graphql.SchemaConfig {
56
+ Query : myNameQuery ,
57
+ })
57
58
if err != nil {
58
59
t .Fatal (err )
59
60
}
@@ -86,17 +87,16 @@ func TestContextPropagated(t *testing.T) {
86
87
func TestHandler_BasicQuery_Pretty (t * testing.T ) {
87
88
expected := & graphql.Result {
88
89
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" ,
92
92
},
93
93
},
94
94
}
95
- queryString := `query=query RebelsShipsQuery { rebels { id, name } }`
95
+ queryString := `query=query HeroNameQuery { hero { name } }`
96
96
req , _ := http .NewRequest ("GET" , fmt .Sprintf ("/graphql?%v" , queryString ), nil )
97
97
98
98
h := handler .New (& handler.Config {
99
- Schema : & starwars . Schema ,
99
+ Schema : & testutil . StarWarsSchema ,
100
100
Pretty : true ,
101
101
})
102
102
result , resp := executeTest (t , h , req )
@@ -111,17 +111,16 @@ func TestHandler_BasicQuery_Pretty(t *testing.T) {
111
111
func TestHandler_BasicQuery_Ugly (t * testing.T ) {
112
112
expected := & graphql.Result {
113
113
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" ,
117
116
},
118
117
},
119
118
}
120
- queryString := `query=query RebelsShipsQuery { rebels { id, name } }`
119
+ queryString := `query=query HeroNameQuery { hero { name } }`
121
120
req , _ := http .NewRequest ("GET" , fmt .Sprintf ("/graphql?%v" , queryString ), nil )
122
121
123
122
h := handler .New (& handler.Config {
124
- Schema : & starwars . Schema ,
123
+ Schema : & testutil . StarWarsSchema ,
125
124
Pretty : false ,
126
125
})
127
126
result , resp := executeTest (t , h , req )
0 commit comments