@@ -13,8 +13,7 @@ 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
17- "golang.org/x/net/context"
16+ "context"
1817)
1918
2019func decodeResponse (t * testing.T , recorder * httptest.ResponseRecorder ) * graphql.Result {
@@ -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) {
8687func 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) {
111111func 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