Skip to content

Commit

Permalink
collect field timing in generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
vektah committed Nov 5, 2019
1 parent 848c627 commit 092ed95
Show file tree
Hide file tree
Showing 15 changed files with 5,696 additions and 4,430 deletions.
16 changes: 9 additions & 7 deletions codegen/field.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Contex
{{- if $object.Stream }}
{{- $null = "nil" }}
{{- end }}

defer func () {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = {{ $null }}
}
}()
rctx := &graphql.ResolverContext{
Object: {{$object.Name|quote}},
Field: field,
Args: nil,
IsMethod: {{or $field.IsMethod $field.IsResolver}},
Stats: graphql.FieldStats{Started: graphql.Now()},
}
defer func () {
rctx.Stats.Completed = graphql.Now()
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = {{ $null }}
}
}()
ctx = graphql.WithResolverContext(ctx, rctx)
{{- if $field.Args }}
rawArgs := field.ArgumentMap(ec.Variables)
Expand All @@ -28,6 +29,7 @@ func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Contex
}
rctx.Args = args
{{- end }}
rctx.Stats.ArgumentsCompleted = graphql.Now()
{{- if $.Directives.LocationDirectives "FIELD" }}
resTmp := ec._fieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {
{{ template "field" $field }}
Expand Down

0 comments on commit 092ed95

Please sign in to comment.