@@ -22,13 +22,16 @@ const (
22
22
23
23
type ResultCallbackFn func (ctx context.Context , params * graphql.Params , result * graphql.Result , responseBody []byte )
24
24
25
+ type ResultCallbackFnV2 func (ctx context.Context , params * graphql.Params , result * graphql.Result , w http.ResponseWriter , r * http.Request )
26
+
25
27
type Handler struct {
26
28
Schema * graphql.Schema
27
29
pretty bool
28
30
graphiql bool
29
31
playground bool
30
32
rootObjectFn RootObjectFn
31
33
resultCallbackFn ResultCallbackFn
34
+ resultCallbackFnV2 ResultCallbackFnV2
32
35
formatErrorFn func (err error ) gqlerrors.FormattedError
33
36
}
34
37
@@ -186,6 +189,10 @@ func (h *Handler) ContextHandler(ctx context.Context, w http.ResponseWriter, r *
186
189
if h .resultCallbackFn != nil {
187
190
h .resultCallbackFn (ctx , & params , result , buff )
188
191
}
192
+
193
+ if h .resultCallbackFnV2 != nil {
194
+ h .resultCallbackFnV2 (ctx , & params , result , w , r )
195
+ }
189
196
}
190
197
191
198
// ServeHTTP provides an entrypoint into executing graphQL queries.
@@ -203,6 +210,7 @@ type Config struct {
203
210
Playground bool
204
211
RootObjectFn RootObjectFn
205
212
ResultCallbackFn ResultCallbackFn
213
+ ResultCallbackFnV2 ResultCallbackFnV2
206
214
FormatErrorFn func (err error ) gqlerrors.FormattedError
207
215
}
208
216
@@ -231,6 +239,7 @@ func New(p *Config) *Handler {
231
239
playground : p .Playground ,
232
240
rootObjectFn : p .RootObjectFn ,
233
241
resultCallbackFn : p .ResultCallbackFn ,
242
+ resultCallbackFnV2 : p .ResultCallbackFnV2 ,
234
243
formatErrorFn : p .FormatErrorFn ,
235
244
}
236
245
}
0 commit comments