@@ -93,12 +93,23 @@ func TestHandler_BasicQuery_Pretty(t *testing.T) {
93
93
},
94
94
},
95
95
}
96
- queryString := `query=query HeroNameQuery { hero { name } }`
96
+ queryString := `query=query HeroNameQuery { hero { name } }&operationName=HeroNameQuery `
97
97
req , _ := http .NewRequest ("GET" , fmt .Sprintf ("/graphql?%v" , queryString ), nil )
98
98
99
+ callbackCalled := false
99
100
h := handler .New (& handler.Config {
100
101
Schema : & testutil .StarWarsSchema ,
101
102
Pretty : true ,
103
+ ResultCallbackFn : func (ctx context.Context , params * graphql.Params , result * graphql.Result , responseBody []byte ) {
104
+ callbackCalled = true
105
+ if params .OperationName != "HeroNameQuery" {
106
+ t .Fatalf ("OperationName passed to callback was not HeroNameQuery: %v" , params .OperationName )
107
+ }
108
+
109
+ if result .HasErrors () {
110
+ t .Fatalf ("unexpected graphql result errors" )
111
+ }
112
+ },
102
113
})
103
114
result , resp := executeTest (t , h , req )
104
115
if resp .Code != http .StatusOK {
@@ -107,6 +118,9 @@ func TestHandler_BasicQuery_Pretty(t *testing.T) {
107
118
if ! reflect .DeepEqual (result , expected ) {
108
119
t .Fatalf ("wrong result, graphql result diff: %v" , testutil .Diff (expected , result ))
109
120
}
121
+ if ! callbackCalled {
122
+ t .Fatalf ("ResultCallbackFn was not called when it should have been" )
123
+ }
110
124
}
111
125
112
126
func TestHandler_BasicQuery_Ugly (t * testing.T ) {
0 commit comments