Skip to content

Commit 4fd5030

Browse files
committed
Add handler calls
1 parent 5ad4dc1 commit 4fd5030

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

executor.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ func Execute(p ExecuteParams) (result *Result) {
2929
if ctx == nil {
3030
ctx = context.Background()
3131
}
32+
handleExtensionsExecutionDidStart(&p)
3233

3334
resultChannel := make(chan *Result)
34-
result = &Result{}
35+
result = &Result{
36+
Extensions: map[string]interface{}{},
37+
}
3538

3639
go func(out chan<- *Result, done <-chan struct{}) {
3740
defer func() {
@@ -63,6 +66,7 @@ func Execute(p ExecuteParams) (result *Result) {
6366
Root: p.Root,
6467
Operation: exeContext.Operation,
6568
})
69+
6670
}(resultChannel, ctx.Done())
6771

6872
select {
@@ -71,6 +75,9 @@ func Execute(p ExecuteParams) (result *Result) {
7175
case r := <-resultChannel:
7276
result = r
7377
}
78+
79+
handleExtensionsExecutionEnded(&p)
80+
result.addExtensionResults(&p)
7481
return
7582
}
7683

@@ -266,6 +273,7 @@ func executeFields(p executeFieldsParams) *Result {
266273
}
267274

268275
func executeSubFields(p executeFieldsParams) map[string]interface{} {
276+
269277
if p.Source == nil {
270278
p.Source = map[string]interface{}{}
271279
}
@@ -620,13 +628,17 @@ func resolveField(eCtx *executionContext, parentType *Object, source interface{}
620628

621629
var resolveFnError error
622630

631+
handleExtensionsResolveFieldDidStart(eCtx.Schema.extensions, eCtx, &info)
632+
623633
result, resolveFnError = resolveFn(ResolveParams{
624634
Source: source,
625635
Args: args,
626636
Info: info,
627637
Context: eCtx.Context,
628638
})
629639

640+
defer handleExtensionsResolveFieldEnded(eCtx.Schema.extensions, eCtx, &info)
641+
630642
if resolveFnError != nil {
631643
panic(resolveFnError)
632644
}

graphql.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,30 @@ func Do(p Params) *Result {
3838
Body: []byte(p.RequestString),
3939
Name: "GraphQL request",
4040
})
41+
handleExtensionsInits(&p)
42+
43+
// parse the source
44+
handleExtensionsParseDidStart(&p)
4145
AST, err := parser.Parse(parser.ParseParams{Source: source})
4246
if err != nil {
47+
handleExtensionsParseEnded(&p, err)
4348
return &Result{
4449
Errors: gqlerrors.FormatErrors(err),
4550
}
4651
}
52+
handleExtensionsParseEnded(&p, err)
53+
54+
// validate document
55+
handleExtensionsValidationDidStart(&p)
4756
validationResult := ValidateDocument(&p.Schema, AST, nil)
4857

4958
if !validationResult.IsValid {
59+
handleExtensionsValidationEnded(&p, validationResult.Errors)
5060
return &Result{
5161
Errors: validationResult.Errors,
5262
}
5363
}
64+
handleExtensionsValidationEnded(&p, validationResult.Errors)
5465

5566
return Execute(ExecuteParams{
5667
Schema: p.Schema,

0 commit comments

Comments
 (0)