Skip to content

Commit

Permalink
refactor Tracer signature
Browse files Browse the repository at this point in the history
  • Loading branch information
vvakame committed Oct 22, 2018
1 parent d319afe commit a3060e8
Show file tree
Hide file tree
Showing 14 changed files with 947 additions and 4,983 deletions.
2 changes: 1 addition & 1 deletion codegen/templates/data.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions codegen/templates/field.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
{{ else }}
// nolint: vetshadow
func (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {
var err error
{{- if $field.Args }}
rawArgs := field.ArgumentMap(ec.Variables)
args, err := {{ $field.ArgsFunc }}(rawArgs)
Expand All @@ -50,11 +49,7 @@
Field: field,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx, err = ec.Tracer.StartFieldTracing(ctx)
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
ctx = ec.Tracer.StartFieldTracing(ctx)
resTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
{{- if $field.IsResolver }}
Expand All @@ -80,11 +75,7 @@
res := resTmp.({{$field.Signature}})
rctx.Result = res
resMarshaler := {{ $field.WriteJson }}
err = ec.Tracer.EndFieldTracing(ctx)
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
ec.Tracer.EndFieldTracing(ctx)
return resMarshaler
}
{{ end }}
Loading

0 comments on commit a3060e8

Please sign in to comment.