diff --git a/.golangci.yml b/.golangci.yml index 320be5449d5..b026536e41a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -29,7 +29,6 @@ linters: - staticcheck - structcheck - stylecheck - - typecheck - unconvert - unused - varcheck diff --git a/appveyor.yml b/appveyor.yml index db475111488..8567dd80fe9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -28,5 +28,6 @@ build: false deploy: false test_script: + - git clean -ffdx - go generate ./... - go test -timeout 20m ./... diff --git a/cmd/root.go b/cmd/root.go index dc2970ac890..d409633af75 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -10,6 +10,7 @@ import ( "github.com/urfave/cli" // Required since otherwise dep will prune away these unused packages before codegen has a chance to run + _ "github.com/99designs/gqlgen/graphql/handler" _ "github.com/99designs/gqlgen/handler" ) diff --git a/codegen/directives.gotpl b/codegen/directives.gotpl index bdfb5aa2f77..e6d2455f6c8 100644 --- a/codegen/directives.gotpl +++ b/codegen/directives.gotpl @@ -115,8 +115,8 @@ func (ec *executionContext) _subscriptionMiddleware(ctx context.Context, obj *as {{ if .Directives.LocationDirectives "FIELD" }} func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) interface{} { {{- if .Directives.LocationDirectives "FIELD" }} - rctx := graphql.GetResolverContext(ctx) - for _, d := range rctx.Field.Directives { + fc := graphql.GetFieldContext(ctx) + for _, d := range fc.Field.Directives { switch d.Name { {{- range $directive := .Directives.LocationDirectives "FIELD" }} case "{{$directive.Name}}": diff --git a/codegen/field.gotpl b/codegen/field.gotpl index f0bf5db7629..993625b7419 100644 --- a/codegen/field.gotpl +++ b/codegen/field.gotpl @@ -5,21 +5,20 @@ func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Contex {{- if $object.Stream }} {{- $null = "nil" }} {{- end }} - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func () { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = {{ $null }} } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: {{$object.Name|quote}}, Field: field, Args: nil, IsMethod: {{or $field.IsMethod $field.IsResolver}}, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) {{- if $field.Args }} rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs) @@ -27,9 +26,8 @@ func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Contex ec.Error(ctx, err) return {{ $null }} } - rctx.Args = args + fc.Args = args {{- end }} - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) {{- if $.Directives.LocationDirectives "FIELD" }} resTmp := ec._fieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) { {{ template "field" $field }} @@ -45,7 +43,7 @@ func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Contex {{- end }} if resTmp == nil { {{- if $field.TypeReference.GQL.NonNull }} - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } {{- end }} @@ -67,8 +65,7 @@ func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Contex } {{- else }} res := resTmp.({{$field.TypeReference.GO | ref}}) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.{{ $field.TypeReference.MarshalFunc }}(ctx, field.Selections, res) {{- end }} } diff --git a/codegen/generated!.gotpl b/codegen/generated!.gotpl index a95e57b625c..e173bfe3c47 100644 --- a/codegen/generated!.gotpl +++ b/codegen/generated!.gotpl @@ -112,105 +112,83 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - {{- if .QueryRoot }} - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - {{ if .Directives.LocationDirectives "QUERY" -}} - data := ec._queryMiddleware(ctx, op, func(ctx context.Context) (interface{}, error){ - return ec._{{.QueryRoot.Name}}(ctx, op.SelectionSet), nil - }) - {{- else -}} - data := ec._{{.QueryRoot.Name}}(ctx, op.SelectionSet) - {{- end }} +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + first := true + + switch rc.Operation.Operation { + {{- if .QueryRoot }} case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { return nil } + first = false + {{ if .Directives.LocationDirectives "QUERY" -}} + data := ec._queryMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){ + return ec._{{.QueryRoot.Name}}(ctx, rc.Operation.SelectionSet), nil + }) + {{- else -}} + data := ec._{{.QueryRoot.Name}}(ctx, rc.Operation.SelectionSet) + {{- end }} var buf bytes.Buffer data.MarshalGQL(&buf) - return buf.Bytes() - }) - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + return &graphql.Response{ + Data: buf.Bytes(), + } } - {{- else }} - return graphql.ErrorResponse(ctx, "queries are not supported") - {{- end }} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - {{- if .MutationRoot }} - ec := executionContext{graphql.GetRequestContext(ctx), e} + {{ end }} - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - {{ if .Directives.LocationDirectives "MUTATION" -}} - data := ec._mutationMiddleware(ctx, op, func(ctx context.Context) (interface{}, error){ - return ec._{{.MutationRoot.Name}}(ctx, op.SelectionSet), nil - }) - {{- else -}} - data := ec._{{.MutationRoot.Name}}(ctx, op.SelectionSet) - {{- end }} + {{- if .MutationRoot }} case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { return nil } + first = false + {{ if .Directives.LocationDirectives "MUTATION" -}} + data := ec._mutationMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){ + return ec._{{.MutationRoot.Name}}(ctx, rc.Operation.SelectionSet), nil + }) + {{- else -}} + data := ec._{{.MutationRoot.Name}}(ctx, rc.Operation.SelectionSet) + {{- end }} var buf bytes.Buffer data.MarshalGQL(&buf) - return buf.Bytes() - }) - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + return &graphql.Response{ + Data: buf.Bytes(), + } } - {{- else }} - return graphql.ErrorResponse(ctx, "mutations are not supported") - {{- end }} -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - {{- if .SubscriptionRoot }} - ec := executionContext{graphql.GetRequestContext(ctx), e} + {{ end }} + {{- if .SubscriptionRoot }} case ast.Subscription: {{ if .Directives.LocationDirectives "SUBSCRIPTION" -}} - next := ec._subscriptionMiddleware(ctx, op, func(ctx context.Context) (interface{}, error){ - return ec._{{.SubscriptionRoot.Name}}(ctx, op.SelectionSet),nil + next := ec._subscriptionMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){ + return ec._{{.SubscriptionRoot.Name}}(ctx, rc.Operation.SelectionSet),nil }) {{- else -}} - next := ec._{{.SubscriptionRoot.Name}}(ctx, op.SelectionSet) + next := ec._{{.SubscriptionRoot.Name}}(ctx, rc.Operation.SelectionSet) {{- end }} - if ec.Errors != nil { - return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) - } var buf bytes.Buffer - return func() *graphql.Response { - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - buf.Reset() - data := next() - - if data == nil { - return nil - } - data.MarshalGQL(&buf) - return buf.Bytes() - }) + return func(ctx context.Context) *graphql.Response { + buf.Reset() + data := next() - if buf == nil { + if data == nil { return nil } + data.MarshalGQL(&buf) return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + Data: buf.Bytes(), } } - {{- else }} - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) - {{- end }} + {{ end }} + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } } type executionContext struct { - *graphql.RequestContext + *graphql.OperationContext *executableSchema } diff --git a/codegen/object.gotpl b/codegen/object.gotpl index 98a75740e66..33775a0b4c3 100644 --- a/codegen/object.gotpl +++ b/codegen/object.gotpl @@ -4,8 +4,8 @@ var {{ $object.Name|lcFirst}}Implementors = {{$object.Implementors}} {{- if .Stream }} func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, {{$object.Name|lcFirst}}Implementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + fields := graphql.CollectFields(ec.OperationContext, sel, {{$object.Name|lcFirst}}Implementors) + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: {{$object.Name|quote}}, }) if len(fields) != 1 { @@ -24,9 +24,9 @@ func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.Selec } {{- else }} func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.SelectionSet{{ if not $object.Root }},obj {{$object.Reference | ref }}{{ end }}) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, {{$object.Name|lcFirst}}Implementors) + fields := graphql.CollectFields(ec.OperationContext, sel, {{$object.Name|lcFirst}}Implementors) {{if $object.Root}} - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: {{$object.Name|quote}}, }) {{end}} diff --git a/codegen/testserver/complexity_test.go b/codegen/testserver/complexity_test.go index a48b74303bb..f5d041c9763 100644 --- a/codegen/testserver/complexity_test.go +++ b/codegen/testserver/complexity_test.go @@ -5,14 +5,17 @@ import ( "testing" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/stretchr/testify/require" ) func TestComplexityCollisions(t *testing.T) { resolvers := &Stub{} - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})) + + c := client.New(srv) resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) { return &OverlappingFields{ @@ -48,7 +51,9 @@ func TestComplexityFuncs(t *testing.T) { cfg.Complexity.OverlappingFields.Foo = func(childComplexity int) int { return 1000 } cfg.Complexity.OverlappingFields.NewFoo = func(childComplexity int) int { return 5 } - c := client.New(handler.GraphQL(NewExecutableSchema(cfg), handler.ComplexityLimit(10))) + srv := handler.NewDefaultServer(NewExecutableSchema(cfg)) + srv.Use(extension.FixedComplexityLimit(10)) + c := client.New(srv) resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) { return &OverlappingFields{ diff --git a/codegen/testserver/directive_test.go b/codegen/testserver/directive_test.go index c8611c1cfce..c201b255726 100644 --- a/codegen/testserver/directive_test.go +++ b/codegen/testserver/directive_test.go @@ -7,7 +7,7 @@ import ( "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) @@ -85,96 +85,95 @@ func TestDirectives(t *testing.T) { resolvers.SubscriptionResolver.DirectiveUnimplemented = func(ctx context.Context) (<-chan *string, error) { return okchan() } + srv := handler.NewDefaultServer(NewExecutableSchema(Config{ + Resolvers: resolvers, + Directives: DirectiveRoot{ + Length: func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message *string) (interface{}, error) { + e := func(msg string) error { + if message == nil { + return fmt.Errorf(msg) + } + return fmt.Errorf(*message) + } + res, err := next(ctx) + if err != nil { + return nil, err + } + + s := res.(string) + if len(s) < min { + return nil, e("too short") + } + if max != nil && len(s) > *max { + return nil, e("too long") + } + return res, nil + }, + Range: func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int) (interface{}, error) { + res, err := next(ctx) + if err != nil { + return nil, err + } + + switch res := res.(type) { + case int: + if min != nil && res < *min { + return nil, fmt.Errorf("too small") + } + if max != nil && res > *max { + return nil, fmt.Errorf("too large") + } + return next(ctx) + + case int64: + if min != nil && int(res) < *min { + return nil, fmt.Errorf("too small") + } + if max != nil && int(res) > *max { + return nil, fmt.Errorf("too large") + } + return next(ctx) + + case *int: + if min != nil && *res < *min { + return nil, fmt.Errorf("too small") + } + if max != nil && *res > *max { + return nil, fmt.Errorf("too large") + } + return next(ctx) + } + return nil, fmt.Errorf("unsupported type %T", res) + }, + Custom: func(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { + return next(ctx) + }, + Logged: func(ctx context.Context, obj interface{}, next graphql.Resolver, id string) (interface{}, error) { + return next(context.WithValue(ctx, "request_id", &id)) + }, + ToNull: func(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { + return nil, nil + }, + Directive1: func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { + return next(ctx) + }, + Directive2: func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { + return next(ctx) + }, + Unimplemented: nil, + }, + })) + + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 1))) + }) + + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 2))) + }) - srv := - handler.GraphQL( - NewExecutableSchema(Config{ - Resolvers: resolvers, - Directives: DirectiveRoot{ - Length: func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message *string) (interface{}, error) { - e := func(msg string) error { - if message == nil { - return fmt.Errorf(msg) - } - return fmt.Errorf(*message) - } - res, err := next(ctx) - if err != nil { - return nil, err - } - - s := res.(string) - if len(s) < min { - return nil, e("too short") - } - if max != nil && len(s) > *max { - return nil, e("too long") - } - return res, nil - }, - Range: func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int) (interface{}, error) { - res, err := next(ctx) - if err != nil { - return nil, err - } - - switch res := res.(type) { - case int: - if min != nil && res < *min { - return nil, fmt.Errorf("too small") - } - if max != nil && res > *max { - return nil, fmt.Errorf("too large") - } - return next(ctx) - - case int64: - if min != nil && int(res) < *min { - return nil, fmt.Errorf("too small") - } - if max != nil && int(res) > *max { - return nil, fmt.Errorf("too large") - } - return next(ctx) - - case *int: - if min != nil && *res < *min { - return nil, fmt.Errorf("too small") - } - if max != nil && *res > *max { - return nil, fmt.Errorf("too large") - } - return next(ctx) - } - return nil, fmt.Errorf("unsupported type %T", res) - }, - Custom: func(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { - return next(ctx) - }, - Logged: func(ctx context.Context, obj interface{}, next graphql.Resolver, id string) (interface{}, error) { - return next(context.WithValue(ctx, "request_id", &id)) - }, - ToNull: func(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { - return nil, nil - }, - Directive1: func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { - return next(ctx) - }, - Directive2: func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { - return next(ctx) - }, - Unimplemented: nil, - }, - }), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 1))) - }), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 2))) - }), - ) c := client.New(srv) t.Run("arg directives", func(t *testing.T) { diff --git a/codegen/testserver/embedded_test.go b/codegen/testserver/embedded_test.go index 4075ab17c96..7760375fb7f 100644 --- a/codegen/testserver/embedded_test.go +++ b/codegen/testserver/embedded_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) @@ -27,7 +27,7 @@ func TestEmbedded(t *testing.T) { return &EmbeddedCase3{&fakeUnexportedEmbeddedInterface{}}, nil } - c := client.New(handler.GraphQL( + c := client.New(handler.NewDefaultServer( NewExecutableSchema(Config{Resolvers: resolver}), )) diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index d3b4980ff6a..31f1fb7a4ca 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -1462,38 +1462,31 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._Query(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) - next := ec._Subscription(ctx, op.SelectionSet) - if ec.Errors != nil { - return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) - } + return &graphql.Response{ + Data: buf.Bytes(), + } + } + case ast.Subscription: + next := ec._Subscription(ctx, rc.Operation.SelectionSet) - var buf bytes.Buffer - return func() *graphql.Response { - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + var buf bytes.Buffer + return func(ctx context.Context) *graphql.Response { buf.Reset() data := next() @@ -1501,23 +1494,19 @@ func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDe return nil } data.MarshalGQL(&buf) - return buf.Bytes() - }) - if buf == nil { - return nil + return &graphql.Response{ + Data: buf.Bytes(), + } } - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { - *graphql.RequestContext + *graphql.OperationContext *executableSchema } @@ -2819,8 +2808,8 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region ************************** directives.gotpl ************************** func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) interface{} { - rctx := graphql.GetResolverContext(ctx) - for _, d := range rctx.Field.Directives { + fc := graphql.GetFieldContext(ctx) + for _, d := range fc.Field.Directives { switch d.Name { case "logged": rawArgs := d.ArgumentMap(ec.Variables) @@ -2851,328 +2840,299 @@ func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj interface{ // region **************************** field.gotpl ***************************** func (ec *executionContext) _A_id(ctx context.Context, field graphql.CollectedField, obj *A) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "A", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _AIt_id(ctx context.Context, field graphql.CollectedField, obj *AIt) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "AIt", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _AbIt_id(ctx context.Context, field graphql.CollectedField, obj *AbIt) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "AbIt", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Autobind_int(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Autobind", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Int, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Autobind_int32(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Autobind", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Int32, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int32) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int32(ctx, field.Selections, res) } func (ec *executionContext) _Autobind_int64(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Autobind", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Int64, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int64(ctx, field.Selections, res) } func (ec *executionContext) _Autobind_idStr(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Autobind", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IdStr, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Autobind_idInt(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Autobind", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IdInt, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2int(ctx, field.Selections, res) } func (ec *executionContext) _B_id(ctx context.Context, field graphql.CollectedField, obj *B) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "B", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _CheckIssue896_id(ctx context.Context, field graphql.CollectedField, obj *CheckIssue896) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "CheckIssue896", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -3182,28 +3142,25 @@ func (ec *executionContext) _CheckIssue896_id(ctx context.Context, field graphql return graphql.Null } res := resTmp.(*int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOInt2ᚖint(ctx, field.Selections, res) } func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Circle", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Radius, nil @@ -3213,28 +3170,25 @@ func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Circle", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Area(), nil @@ -3244,28 +3198,25 @@ func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Content_Post_foo(ctx context.Context, field graphql.CollectedField, obj *ContentPost) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Content_Post", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Foo, nil @@ -3275,28 +3226,25 @@ func (ec *executionContext) _Content_Post_foo(ctx context.Context, field graphql return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Content_User_foo(ctx context.Context, field graphql.CollectedField, obj *ContentUser) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Content_User", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Foo, nil @@ -3306,130 +3254,118 @@ func (ec *executionContext) _Content_User_foo(ctx context.Context, field graphql return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase1) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "EmbeddedCase1", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ExportedEmbeddedPointerExportedMethod(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase2) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "EmbeddedCase2", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.UnexportedEmbeddedPointerExportedMethod(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase3) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "EmbeddedCase3", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.UnexportedEmbeddedInterfaceExportedMethod(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _EmbeddedDefaultScalar_value(ctx context.Context, field graphql.CollectedField, obj *EmbeddedDefaultScalar) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "EmbeddedDefaultScalar", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Value, nil @@ -3439,28 +3375,25 @@ func (ec *executionContext) _EmbeddedDefaultScalar_value(ctx context.Context, fi return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalODefaultScalarImplementation2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "EmbeddedPointer", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -3470,28 +3403,25 @@ func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graph return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "EmbeddedPointer", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Title, nil @@ -3501,62 +3431,56 @@ func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field gr return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Error", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Error", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ErrorOnNonRequiredField() @@ -3566,266 +3490,242 @@ func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Error", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ErrorOnRequiredField() }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Error", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.NilOnRequiredField(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Errors_a(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Errors", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Errors().A(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*Error) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res) } func (ec *executionContext) _Errors_b(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Errors", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Errors().B(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*Error) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res) } func (ec *executionContext) _Errors_c(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Errors", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Errors().C(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*Error) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res) } func (ec *executionContext) _Errors_d(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Errors", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Errors().D(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*Error) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res) } func (ec *executionContext) _Errors_e(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Errors", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Errors().E(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*Error) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res) } func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "ForcedResolver", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.ForcedResolver().Field(rctx, obj) @@ -3835,232 +3735,211 @@ func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field gra return graphql.Null } res := resTmp.(*Circle) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx, field.Selections, res) } func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "InnerObject", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "InvalidIdentifier", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection1.It) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "It", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _LoopA_b(ctx context.Context, field graphql.CollectedField, obj *LoopA) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "LoopA", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.B, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*LoopB) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐLoopB(ctx, field.Selections, res) } func (ec *executionContext) _LoopB_a(ctx context.Context, field graphql.CollectedField, obj *LoopB) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "LoopB", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.A, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*LoopA) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐLoopA(ctx, field.Selections, res) } func (ec *executionContext) _Map_id(ctx context.Context, field graphql.CollectedField, obj *Map) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Map", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MapStringInterfaceType", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children switch v := obj["a"].(type) { @@ -4079,28 +3958,25 @@ func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _MapStringInterfaceType_b(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MapStringInterfaceType", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children switch v := obj["b"].(type) { @@ -4119,130 +3995,118 @@ func (ec *executionContext) _MapStringInterfaceType_b(ctx context.Context, field return graphql.Null } res := resTmp.(*int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOInt2ᚖint(ctx, field.Selections, res) } func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "ModelMethods", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.ModelMethods().ResolverField(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "ModelMethods", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.NoContext(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "ModelMethods", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.WithContext(ctx), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _ObjectDirectives_text(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "ObjectDirectives", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -4281,34 +4145,31 @@ func (ec *executionContext) _ObjectDirectives_text(ctx context.Context, field gr }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _ObjectDirectives_nullableText(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "ObjectDirectives", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -4338,28 +4199,25 @@ func (ec *executionContext) _ObjectDirectives_nullableText(ctx context.Context, return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _ObjectDirectivesWithCustomGoModel_nullableText(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectivesWithCustomGoModel) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "ObjectDirectivesWithCustomGoModel", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -4389,518 +4247,473 @@ func (ec *executionContext) _ObjectDirectivesWithCustomGoModel_nullableText(ctx return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "OuterObject", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Inner, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*InnerObject) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx, field.Selections, res) } func (ec *executionContext) _OverlappingFields_oneFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "OverlappingFields", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Foo, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _OverlappingFields_twoFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "OverlappingFields", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Foo, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _OverlappingFields_oldFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "OverlappingFields", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.OverlappingFields().OldFoo(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _OverlappingFields_newFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "OverlappingFields", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.NewFoo, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _OverlappingFields_new_foo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "OverlappingFields", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.NewFoo, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Panics", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Panics().FieldScalarMarshal(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]MarshalPanic) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanicᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Panics", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Panics_fieldFuncMarshal_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.FieldFuncMarshal(ctx, args["u"].([]MarshalPanic)), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]MarshalPanic) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanicᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Panics", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Panics_argUnmarshal_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Panics().ArgUnmarshal(rctx, obj, args["u"].([]MarshalPanic)) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Primitive_value(ctx context.Context, field graphql.CollectedField, obj *Primitive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Primitive", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Primitive().Value(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Primitive_squared(ctx context.Context, field graphql.CollectedField, obj *Primitive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Primitive", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Squared(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _PrimitiveString_value(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "PrimitiveString", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.PrimitiveString().Value(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _PrimitiveString_doubled(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "PrimitiveString", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Doubled(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _PrimitiveString_len(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "PrimitiveString", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.PrimitiveString().Len(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().InvalidIdentifier(rctx) @@ -4910,28 +4723,25 @@ func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field return graphql.Null } res := resTmp.(*invalid_packagename.InvalidIdentifier) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx, field.Selections, res) } func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Collision(rctx) @@ -4941,35 +4751,32 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql. return graphql.Null } res := resTmp.(*introspection1.It) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx, field.Selections, res) } func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_mapInput_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().MapInput(rctx, args["input"].(map[string]interface{})) @@ -4979,35 +4786,32 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) } func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_recursive_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Recursive(rctx, args["input"].(*RecursiveInputSlice)) @@ -5017,35 +4821,32 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql. return graphql.Null } res := resTmp.(*bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) } func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_nestedInputs_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().NestedInputs(rctx, args["input"].([][]*OuterInput)) @@ -5055,28 +4856,25 @@ func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graph return graphql.Null } res := resTmp.(*bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) } func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().NestedOutputs(rctx) @@ -5086,28 +4884,25 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap return graphql.Null } res := resTmp.([][]*OuterObject) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, field.Selections, res) } func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().ModelMethods(rctx) @@ -5117,76 +4912,70 @@ func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graph return graphql.Null } res := resTmp.(*ModelMethods) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx, field.Selections, res) } func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_user_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().User(rctx, args["id"].(int)) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_nullableArg_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().NullableArg(rctx, args["arg"].(*int)) @@ -5196,103 +4985,94 @@ func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphq return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_inputSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_inputSlice_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().InputSlice(rctx, args["arg"].([]string)) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().ShapeUnion(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(ShapeUnion) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShapeUnion(ctx, field.Selections, res) } func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Autobind(rctx) @@ -5302,62 +5082,56 @@ func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*Autobind) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐAutobind(ctx, field.Selections, res) } func (ec *executionContext) _Query_deprecatedField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DeprecatedField(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Query_overlapping(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Overlapping(rctx) @@ -5367,35 +5141,32 @@ func (ec *executionContext) _Query_overlapping(ctx context.Context, field graphq return graphql.Null } res := resTmp.(*OverlappingFields) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOverlappingFields(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_directiveArg_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DirectiveArg(rctx, args["arg"].(string)) @@ -5405,35 +5176,32 @@ func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graph return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_directiveNullableArg_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DirectiveNullableArg(rctx, args["arg"].(*int), args["arg2"].(*int), args["arg3"].(*string)) @@ -5443,35 +5211,32 @@ func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, fie return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_directiveInputNullable_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DirectiveInputNullable(rctx, args["arg"].(*InputDirectives)) @@ -5481,35 +5246,32 @@ func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, f return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_directiveInput_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DirectiveInput(rctx, args["arg"].(InputDirectives)) @@ -5519,35 +5281,32 @@ func (ec *executionContext) _Query_directiveInput(ctx context.Context, field gra return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveInputType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_directiveInputType_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DirectiveInputType(rctx, args["arg"].(InnerInput)) @@ -5557,28 +5316,25 @@ func (ec *executionContext) _Query_directiveInputType(ctx context.Context, field return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DirectiveObject(rctx) @@ -5588,28 +5344,25 @@ func (ec *executionContext) _Query_directiveObject(ctx context.Context, field gr return graphql.Null } res := resTmp.(*ObjectDirectives) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐObjectDirectives(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveObjectWithCustomGoModel(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DirectiveObjectWithCustomGoModel(rctx) @@ -5619,35 +5372,32 @@ func (ec *executionContext) _Query_directiveObjectWithCustomGoModel(ctx context. return graphql.Null } res := resTmp.(*ObjectDirectivesWithCustomGoModel) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOObjectDirectivesWithCustomGoModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐObjectDirectivesWithCustomGoModel(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveFieldDef(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_directiveFieldDef_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -5682,34 +5432,31 @@ func (ec *executionContext) _Query_directiveFieldDef(ctx context.Context, field }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DirectiveField(rctx) @@ -5719,28 +5466,25 @@ func (ec *executionContext) _Query_directiveField(ctx context.Context, field gra return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveDouble(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -5776,28 +5520,25 @@ func (ec *executionContext) _Query_directiveDouble(ctx context.Context, field gr return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -5827,28 +5568,25 @@ func (ec *executionContext) _Query_directiveUnimplemented(ctx context.Context, f return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_embeddedCase1(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().EmbeddedCase1(rctx) @@ -5858,28 +5596,25 @@ func (ec *executionContext) _Query_embeddedCase1(ctx context.Context, field grap return graphql.Null } res := resTmp.(*EmbeddedCase1) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase1(ctx, field.Selections, res) } func (ec *executionContext) _Query_embeddedCase2(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().EmbeddedCase2(rctx) @@ -5889,28 +5624,25 @@ func (ec *executionContext) _Query_embeddedCase2(ctx context.Context, field grap return graphql.Null } res := resTmp.(*EmbeddedCase2) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOEmbeddedCase22ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase2(ctx, field.Selections, res) } func (ec *executionContext) _Query_embeddedCase3(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().EmbeddedCase3(rctx) @@ -5920,28 +5652,25 @@ func (ec *executionContext) _Query_embeddedCase3(ctx context.Context, field grap return graphql.Null } res := resTmp.(*EmbeddedCase3) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase3(ctx, field.Selections, res) } func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Shapes(rctx) @@ -5951,28 +5680,25 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.([]Shape) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, field.Selections, res) } func (ec *executionContext) _Query_noShape(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -6002,28 +5728,25 @@ func (ec *executionContext) _Query_noShape(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.(Shape) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, field.Selections, res) } func (ec *executionContext) _Query_issue896a(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Issue896a(rctx) @@ -6033,35 +5756,32 @@ func (ec *executionContext) _Query_issue896a(ctx context.Context, field graphql. return graphql.Null } res := resTmp.([]*CheckIssue896) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896ᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_mapStringInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_mapStringInterface_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().MapStringInterface(rctx, args["in"].(map[string]interface{})) @@ -6071,35 +5791,32 @@ func (ec *executionContext) _Query_mapStringInterface(ctx context.Context, field return graphql.Null } res := resTmp.(map[string]interface{}) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOMapStringInterfaceType2map(ctx, field.Selections, res) } func (ec *executionContext) _Query_mapNestedStringInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_mapNestedStringInterface_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().MapNestedStringInterface(rctx, args["in"].(*NestedMapInput)) @@ -6109,28 +5826,25 @@ func (ec *executionContext) _Query_mapNestedStringInterface(ctx context.Context, return graphql.Null } res := resTmp.(map[string]interface{}) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOMapStringInterfaceType2map(ctx, field.Selections, res) } func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().ErrorBubble(rctx) @@ -6140,28 +5854,25 @@ func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphq return graphql.Null } res := resTmp.(*Error) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res) } func (ec *executionContext) _Query_errors(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Errors(rctx) @@ -6171,62 +5882,56 @@ func (ec *executionContext) _Query_errors(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*Errors) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐErrors(ctx, field.Selections, res) } func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Valid(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Panics(rctx) @@ -6236,137 +5941,125 @@ func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*Panics) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPanics(ctx, field.Selections, res) } func (ec *executionContext) _Query_primitiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().PrimitiveObject(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]Primitive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPrimitiveᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_primitiveStringObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().PrimitiveStringObject(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]PrimitiveString) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPrimitiveStringᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_defaultScalar_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DefaultScalar(rctx, args["arg"].(string)) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNDefaultScalarImplementation2string(ctx, field.Selections, res) } func (ec *executionContext) _Query_slices(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Slices(rctx) @@ -6376,103 +6069,94 @@ func (ec *executionContext) _Query_slices(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*Slices) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐSlices(ctx, field.Selections, res) } func (ec *executionContext) _Query_scalarSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().ScalarSlice(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]byte) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBytes2ᚕbyte(ctx, field.Selections, res) } func (ec *executionContext) _Query_fallback(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_fallback_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Fallback(rctx, args["arg"].(FallbackToStringEncoding)) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(FallbackToStringEncoding) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx, field.Selections, res) } func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().OptionalUnion(rctx) @@ -6482,28 +6166,25 @@ func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field grap return graphql.Null } res := resTmp.(TestUnion) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐTestUnion(ctx, field.Selections, res) } func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().ValidType(rctx) @@ -6513,103 +6194,94 @@ func (ec *executionContext) _Query_validType(ctx context.Context, field graphql. return graphql.Null } res := resTmp.(*ValidType) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidType(ctx, field.Selections, res) } func (ec *executionContext) _Query_wrappedStruct(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().WrappedStruct(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*WrappedStruct) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNWrappedStruct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedStruct(ctx, field.Selections, res) } func (ec *executionContext) _Query_wrappedScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().WrappedScalar(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(WrappedScalar) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedScalar(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) @@ -6619,28 +6291,25 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() @@ -6650,28 +6319,25 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Rectangle", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Length, nil @@ -6681,28 +6347,25 @@ func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql return graphql.Null } res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Rectangle", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Width, nil @@ -6712,28 +6375,25 @@ func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql. return graphql.Null } res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Rectangle", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Area(), nil @@ -6743,28 +6403,25 @@ func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Slices_test1(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Slices", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Test1, nil @@ -6774,28 +6431,25 @@ func (ec *executionContext) _Slices_test1(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.([]*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚕᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Slices_test2(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Slices", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Test2, nil @@ -6805,103 +6459,94 @@ func (ec *executionContext) _Slices_test2(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Slices_test3(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Slices", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Test3, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2ᚕᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Slices_test4(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Slices", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Test4, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Subscription", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Subscription().Updated(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return nil @@ -6922,29 +6567,27 @@ func (ec *executionContext) _Subscription_updated(ctx context.Context, field gra } func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Subscription", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Subscription().InitPayload(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return nil @@ -6965,29 +6608,27 @@ func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field } func (ec *executionContext) _Subscription_directiveArg(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Subscription", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Subscription_directiveArg_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return nil } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Subscription().DirectiveArg(rctx, args["arg"].(string)) @@ -7012,29 +6653,27 @@ func (ec *executionContext) _Subscription_directiveArg(ctx context.Context, fiel } func (ec *executionContext) _Subscription_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Subscription", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Subscription_directiveNullableArg_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return nil } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Subscription().DirectiveNullableArg(rctx, args["arg"].(*int), args["arg2"].(*int), args["arg3"].(*string)) @@ -7059,22 +6698,20 @@ func (ec *executionContext) _Subscription_directiveNullableArg(ctx context.Conte } func (ec *executionContext) _Subscription_directiveDouble(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Subscription", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -7125,22 +6762,20 @@ func (ec *executionContext) _Subscription_directiveDouble(ctx context.Context, f } func (ec *executionContext) _Subscription_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Subscription", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -7185,22 +6820,20 @@ func (ec *executionContext) _Subscription_directiveUnimplemented(ctx context.Con } func (ec *executionContext) _Subscription_issue896b(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Subscription", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Subscription().Issue896b(rctx) @@ -7225,124 +6858,113 @@ func (ec *executionContext) _Subscription_issue896b(ctx context.Context, field g } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _User_friends(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.User().Friends(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUserᚄ(ctx, field.Selections, res) } func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Created, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(time.Time) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _User_updated(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Updated, nil @@ -7352,314 +6974,287 @@ func (ec *executionContext) _User_updated(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*time.Time) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _ValidType_differentCase(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "ValidType", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DifferentCase, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _ValidType_different_case(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "ValidType", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DifferentCaseOld, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _ValidType_validInputKeywords(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "ValidType", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_ValidType_validInputKeywords_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ValidInputKeywords, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "ValidType", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_ValidType_validArgs_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ValidArgs, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _WrappedStruct_name(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "WrappedStruct", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _XXIt_id(ctx context.Context, field graphql.CollectedField, obj *XXIt) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "XXIt", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _XxIt_id(ctx context.Context, field graphql.CollectedField, obj *XxIt) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "XxIt", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -7669,130 +7264,118 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -7802,62 +7385,56 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -7867,62 +7444,56 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -7932,130 +7503,118 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -8065,62 +7624,56 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -8130,62 +7683,56 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil @@ -8195,96 +7742,87 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil @@ -8294,28 +7832,25 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil @@ -8325,96 +7860,87 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil @@ -8424,28 +7950,25 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -8455,35 +7978,32 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil @@ -8493,28 +8013,25 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil @@ -8524,28 +8041,25 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil @@ -8555,35 +8069,32 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil @@ -8593,28 +8104,25 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil @@ -8624,28 +8132,25 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil @@ -8655,76 +8160,69 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _asdfIt_id(ctx context.Context, field graphql.CollectedField, obj *AsdfIt) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "asdfIt", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _iIt_id(ctx context.Context, field graphql.CollectedField, obj *IIt) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "iIt", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } @@ -9189,7 +8687,7 @@ func (ec *executionContext) _TestUnion(ctx context.Context, sel ast.SelectionSet var aImplementors = []string{"A", "TestUnion"} func (ec *executionContext) _A(ctx context.Context, sel ast.SelectionSet, obj *A) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, aImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, aImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9216,7 +8714,7 @@ func (ec *executionContext) _A(ctx context.Context, sel ast.SelectionSet, obj *A var aItImplementors = []string{"AIt"} func (ec *executionContext) _AIt(ctx context.Context, sel ast.SelectionSet, obj *AIt) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, aItImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, aItImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9243,7 +8741,7 @@ func (ec *executionContext) _AIt(ctx context.Context, sel ast.SelectionSet, obj var abItImplementors = []string{"AbIt"} func (ec *executionContext) _AbIt(ctx context.Context, sel ast.SelectionSet, obj *AbIt) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, abItImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, abItImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9270,7 +8768,7 @@ func (ec *executionContext) _AbIt(ctx context.Context, sel ast.SelectionSet, obj var autobindImplementors = []string{"Autobind"} func (ec *executionContext) _Autobind(ctx context.Context, sel ast.SelectionSet, obj *Autobind) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, autobindImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, autobindImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9317,7 +8815,7 @@ func (ec *executionContext) _Autobind(ctx context.Context, sel ast.SelectionSet, var bImplementors = []string{"B", "TestUnion"} func (ec *executionContext) _B(ctx context.Context, sel ast.SelectionSet, obj *B) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, bImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, bImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9344,7 +8842,7 @@ func (ec *executionContext) _B(ctx context.Context, sel ast.SelectionSet, obj *B var checkIssue896Implementors = []string{"CheckIssue896"} func (ec *executionContext) _CheckIssue896(ctx context.Context, sel ast.SelectionSet, obj *CheckIssue896) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, checkIssue896Implementors) + fields := graphql.CollectFields(ec.OperationContext, sel, checkIssue896Implementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9368,7 +8866,7 @@ func (ec *executionContext) _CheckIssue896(ctx context.Context, sel ast.Selectio var circleImplementors = []string{"Circle", "Shape", "ShapeUnion"} func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, circleImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, circleImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9394,7 +8892,7 @@ func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, o var content_PostImplementors = []string{"Content_Post", "Content_Child"} func (ec *executionContext) _Content_Post(ctx context.Context, sel ast.SelectionSet, obj *ContentPost) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, content_PostImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, content_PostImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9418,7 +8916,7 @@ func (ec *executionContext) _Content_Post(ctx context.Context, sel ast.Selection var content_UserImplementors = []string{"Content_User", "Content_Child"} func (ec *executionContext) _Content_User(ctx context.Context, sel ast.SelectionSet, obj *ContentUser) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, content_UserImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, content_UserImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9442,7 +8940,7 @@ func (ec *executionContext) _Content_User(ctx context.Context, sel ast.Selection var embeddedCase1Implementors = []string{"EmbeddedCase1"} func (ec *executionContext) _EmbeddedCase1(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase1) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, embeddedCase1Implementors) + fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase1Implementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9469,7 +8967,7 @@ func (ec *executionContext) _EmbeddedCase1(ctx context.Context, sel ast.Selectio var embeddedCase2Implementors = []string{"EmbeddedCase2"} func (ec *executionContext) _EmbeddedCase2(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase2) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, embeddedCase2Implementors) + fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase2Implementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9496,7 +8994,7 @@ func (ec *executionContext) _EmbeddedCase2(ctx context.Context, sel ast.Selectio var embeddedCase3Implementors = []string{"EmbeddedCase3"} func (ec *executionContext) _EmbeddedCase3(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase3) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, embeddedCase3Implementors) + fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase3Implementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9523,7 +9021,7 @@ func (ec *executionContext) _EmbeddedCase3(ctx context.Context, sel ast.Selectio var embeddedDefaultScalarImplementors = []string{"EmbeddedDefaultScalar"} func (ec *executionContext) _EmbeddedDefaultScalar(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedDefaultScalar) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, embeddedDefaultScalarImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, embeddedDefaultScalarImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9547,7 +9045,7 @@ func (ec *executionContext) _EmbeddedDefaultScalar(ctx context.Context, sel ast. var embeddedPointerImplementors = []string{"EmbeddedPointer"} func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedPointerModel) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, embeddedPointerImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, embeddedPointerImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9573,7 +9071,7 @@ func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.Select var errorImplementors = []string{"Error"} func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, obj *Error) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, errorImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, errorImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9612,7 +9110,7 @@ func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, ob var errorsImplementors = []string{"Errors"} func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, obj *Errors) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, errorsImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, errorsImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9704,7 +9202,7 @@ func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, o var forcedResolverImplementors = []string{"ForcedResolver"} func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.SelectionSet, obj *ForcedResolver) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, forcedResolverImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, forcedResolverImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9737,7 +9235,7 @@ func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.Selecti var innerObjectImplementors = []string{"InnerObject"} func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionSet, obj *InnerObject) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, innerObjectImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, innerObjectImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9764,7 +9262,7 @@ func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionS var invalidIdentifierImplementors = []string{"InvalidIdentifier"} func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.SelectionSet, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, invalidIdentifierImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, invalidIdentifierImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9791,7 +9289,7 @@ func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.Sele var itImplementors = []string{"It"} func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj *introspection1.It) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, itImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, itImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9818,7 +9316,7 @@ func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj * var loopAImplementors = []string{"LoopA"} func (ec *executionContext) _LoopA(ctx context.Context, sel ast.SelectionSet, obj *LoopA) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, loopAImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, loopAImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9845,7 +9343,7 @@ func (ec *executionContext) _LoopA(ctx context.Context, sel ast.SelectionSet, ob var loopBImplementors = []string{"LoopB"} func (ec *executionContext) _LoopB(ctx context.Context, sel ast.SelectionSet, obj *LoopB) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, loopBImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, loopBImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9872,7 +9370,7 @@ func (ec *executionContext) _LoopB(ctx context.Context, sel ast.SelectionSet, ob var mapImplementors = []string{"Map"} func (ec *executionContext) _Map(ctx context.Context, sel ast.SelectionSet, obj *Map) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, mapImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, mapImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9899,7 +9397,7 @@ func (ec *executionContext) _Map(ctx context.Context, sel ast.SelectionSet, obj var mapStringInterfaceTypeImplementors = []string{"MapStringInterfaceType"} func (ec *executionContext) _MapStringInterfaceType(ctx context.Context, sel ast.SelectionSet, obj map[string]interface{}) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, mapStringInterfaceTypeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, mapStringInterfaceTypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9925,7 +9423,7 @@ func (ec *executionContext) _MapStringInterfaceType(ctx context.Context, sel ast var modelMethodsImplementors = []string{"ModelMethods"} func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.SelectionSet, obj *ModelMethods) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, modelMethodsImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, modelMethodsImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -9980,7 +9478,7 @@ func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.Selection var objectDirectivesImplementors = []string{"ObjectDirectives"} func (ec *executionContext) _ObjectDirectives(ctx context.Context, sel ast.SelectionSet, obj *ObjectDirectives) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, objectDirectivesImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, objectDirectivesImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -10009,7 +9507,7 @@ func (ec *executionContext) _ObjectDirectives(ctx context.Context, sel ast.Selec var objectDirectivesWithCustomGoModelImplementors = []string{"ObjectDirectivesWithCustomGoModel"} func (ec *executionContext) _ObjectDirectivesWithCustomGoModel(ctx context.Context, sel ast.SelectionSet, obj *ObjectDirectivesWithCustomGoModel) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, objectDirectivesWithCustomGoModelImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, objectDirectivesWithCustomGoModelImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -10033,7 +9531,7 @@ func (ec *executionContext) _ObjectDirectivesWithCustomGoModel(ctx context.Conte var outerObjectImplementors = []string{"OuterObject"} func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionSet, obj *OuterObject) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, outerObjectImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, outerObjectImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -10060,7 +9558,7 @@ func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionS var overlappingFieldsImplementors = []string{"OverlappingFields"} func (ec *executionContext) _OverlappingFields(ctx context.Context, sel ast.SelectionSet, obj *OverlappingFields) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, overlappingFieldsImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, overlappingFieldsImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -10116,7 +9614,7 @@ func (ec *executionContext) _OverlappingFields(ctx context.Context, sel ast.Sele var panicsImplementors = []string{"Panics"} func (ec *executionContext) _Panics(ctx context.Context, sel ast.SelectionSet, obj *Panics) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, panicsImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, panicsImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -10180,7 +9678,7 @@ func (ec *executionContext) _Panics(ctx context.Context, sel ast.SelectionSet, o var primitiveImplementors = []string{"Primitive"} func (ec *executionContext) _Primitive(ctx context.Context, sel ast.SelectionSet, obj *Primitive) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, primitiveImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, primitiveImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -10221,7 +9719,7 @@ func (ec *executionContext) _Primitive(ctx context.Context, sel ast.SelectionSet var primitiveStringImplementors = []string{"PrimitiveString"} func (ec *executionContext) _PrimitiveString(ctx context.Context, sel ast.SelectionSet, obj *PrimitiveString) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, primitiveStringImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, primitiveStringImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -10276,9 +9774,9 @@ func (ec *executionContext) _PrimitiveString(ctx context.Context, sel ast.Select var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, queryImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) @@ -10862,7 +10360,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var rectangleImplementors = []string{"Rectangle", "Shape", "ShapeUnion"} func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, rectangleImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, rectangleImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -10890,7 +10388,7 @@ func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet var slicesImplementors = []string{"Slices"} func (ec *executionContext) _Slices(ctx context.Context, sel ast.SelectionSet, obj *Slices) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, slicesImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, slicesImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -10926,8 +10424,8 @@ func (ec *executionContext) _Slices(ctx context.Context, sel ast.SelectionSet, o var subscriptionImplementors = []string{"Subscription"} func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, subscriptionImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + fields := graphql.CollectFields(ec.OperationContext, sel, subscriptionImplementors) + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Subscription", }) if len(fields) != 1 { @@ -10958,7 +10456,7 @@ func (ec *executionContext) _Subscription(ctx context.Context, sel ast.Selection var userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, userImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -11006,7 +10504,7 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj var validTypeImplementors = []string{"ValidType"} func (ec *executionContext) _ValidType(ctx context.Context, sel ast.SelectionSet, obj *ValidType) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, validTypeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, validTypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -11048,7 +10546,7 @@ func (ec *executionContext) _ValidType(ctx context.Context, sel ast.SelectionSet var wrappedStructImplementors = []string{"WrappedStruct"} func (ec *executionContext) _WrappedStruct(ctx context.Context, sel ast.SelectionSet, obj *WrappedStruct) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, wrappedStructImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, wrappedStructImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -11075,7 +10573,7 @@ func (ec *executionContext) _WrappedStruct(ctx context.Context, sel ast.Selectio var xXItImplementors = []string{"XXIt"} func (ec *executionContext) _XXIt(ctx context.Context, sel ast.SelectionSet, obj *XXIt) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, xXItImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, xXItImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -11102,7 +10600,7 @@ func (ec *executionContext) _XXIt(ctx context.Context, sel ast.SelectionSet, obj var xxItImplementors = []string{"XxIt"} func (ec *executionContext) _XxIt(ctx context.Context, sel ast.SelectionSet, obj *XxIt) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, xxItImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, xxItImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -11129,7 +10627,7 @@ func (ec *executionContext) _XxIt(ctx context.Context, sel ast.SelectionSet, obj var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -11168,7 +10666,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -11204,7 +10702,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __FieldImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -11250,7 +10748,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __InputValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -11286,7 +10784,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __SchemaImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -11327,7 +10825,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __TypeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -11370,7 +10868,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o var asdfItImplementors = []string{"asdfIt"} func (ec *executionContext) _asdfIt(ctx context.Context, sel ast.SelectionSet, obj *AsdfIt) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, asdfItImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, asdfItImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -11397,7 +10895,7 @@ func (ec *executionContext) _asdfIt(ctx context.Context, sel ast.SelectionSet, o var iItImplementors = []string{"iIt"} func (ec *executionContext) _iIt(ctx context.Context, sel ast.SelectionSet, obj *IIt) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, iItImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, iItImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -11432,7 +10930,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -11446,7 +10944,7 @@ func (ec *executionContext) unmarshalNBytes2ᚕbyte(ctx context.Context, v inter func (ec *executionContext) marshalNBytes2ᚕbyte(ctx context.Context, sel ast.SelectionSet, v []byte) graphql.Marshaler { res := MarshalBytes(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -11459,7 +10957,7 @@ func (ec *executionContext) marshalNCheckIssue8962githubᚗcomᚋ99designsᚋgql func (ec *executionContext) marshalNCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v *CheckIssue896) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -11474,7 +10972,7 @@ func (ec *executionContext) unmarshalNDefaultScalarImplementation2string(ctx con func (ec *executionContext) marshalNDefaultScalarImplementation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -11487,7 +10985,7 @@ func (ec *executionContext) marshalNError2githubᚗcomᚋ99designsᚋgqlgenᚋco func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -11503,7 +11001,7 @@ func (ec *executionContext) unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99 func (ec *executionContext) marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx context.Context, sel ast.SelectionSet, v FallbackToStringEncoding) graphql.Marshaler { res := graphql.MarshalString(string(v)) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -11517,7 +11015,7 @@ func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalIntID(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -11531,7 +11029,7 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalID(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -11568,7 +11066,7 @@ func (ec *executionContext) marshalNInnerObject2githubᚗcomᚋ99designsᚋgqlge func (ec *executionContext) marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v *InnerObject) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -11587,7 +11085,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalInt(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -11601,7 +11099,7 @@ func (ec *executionContext) unmarshalNInt2int32(ctx context.Context, v interface func (ec *executionContext) marshalNInt2int32(ctx context.Context, sel ast.SelectionSet, v int32) graphql.Marshaler { res := graphql.MarshalInt32(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -11615,7 +11113,7 @@ func (ec *executionContext) unmarshalNInt2int64(ctx context.Context, v interface func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.SelectionSet, v int64) graphql.Marshaler { res := graphql.MarshalInt64(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -11628,7 +11126,7 @@ func (ec *executionContext) marshalNLoopA2githubᚗcomᚋ99designsᚋgqlgenᚋco func (ec *executionContext) marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐLoopA(ctx context.Context, sel ast.SelectionSet, v *LoopA) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -11642,7 +11140,7 @@ func (ec *executionContext) marshalNLoopB2githubᚗcomᚋ99designsᚋgqlgenᚋco func (ec *executionContext) marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐLoopB(ctx context.Context, sel ast.SelectionSet, v *LoopB) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -11701,11 +11199,11 @@ func (ec *executionContext) marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -11742,11 +11240,11 @@ func (ec *executionContext) marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designs } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -11776,7 +11274,7 @@ func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋ99desig func (ec *executionContext) marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShapeUnion(ctx context.Context, sel ast.SelectionSet, v ShapeUnion) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -11791,7 +11289,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -11866,7 +11364,7 @@ func (ec *executionContext) unmarshalNString2ᚖstring(ctx context.Context, v in func (ec *executionContext) marshalNString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -11881,7 +11379,7 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { res := graphql.MarshalTime(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -11895,7 +11393,7 @@ func (ec *executionContext) unmarshalNUUID2string(ctx context.Context, v interfa func (ec *executionContext) marshalNUUID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -11915,11 +11413,11 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -11945,7 +11443,7 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -11961,7 +11459,7 @@ func (ec *executionContext) unmarshalNWrappedScalar2githubᚗcomᚋ99designsᚋg func (ec *executionContext) marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedScalar(ctx context.Context, sel ast.SelectionSet, v WrappedScalar) graphql.Marshaler { res := graphql.MarshalString(string(v)) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -11974,7 +11472,7 @@ func (ec *executionContext) marshalNWrappedStruct2githubᚗcomᚋ99designsᚋgql func (ec *executionContext) marshalNWrappedStruct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedStruct(ctx context.Context, sel ast.SelectionSet, v *WrappedStruct) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -11995,11 +11493,11 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -12030,7 +11528,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -12066,11 +11564,11 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -12115,11 +11613,11 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -12156,11 +11654,11 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -12186,7 +11684,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -12201,7 +11699,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -12265,11 +11763,11 @@ func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designs } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -12305,11 +11803,11 @@ func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designs } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -12633,11 +12131,11 @@ func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99design } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -12673,11 +12171,11 @@ func (ec *executionContext) marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designs } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -12781,11 +12279,11 @@ func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -12995,11 +12493,11 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -13035,11 +12533,11 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -13075,11 +12573,11 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -13130,11 +12628,11 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index 38362c131f5..7868045adc8 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -5,21 +5,14 @@ package testserver import ( "context" - "net/http" "reflect" "testing" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) -func TestGeneratedResolversAreValid(t *testing.T) { - http.Handle("/query", handler.GraphQL(NewExecutableSchema(Config{ - Resolvers: &Resolver{}, - }))) -} - func TestForcedResolverFieldIsPointer(t *testing.T) { field, ok := reflect.TypeOf((*ForcedResolverResolver)(nil)).Elem().MethodByName("Field") require.True(t, ok) @@ -39,7 +32,8 @@ func TestUnionFragments(t *testing.T) { return &Circle{Radius: 32}, nil } - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})) + c := client.New(srv) t.Run("inline fragment on union", func(t *testing.T) { var resp struct { diff --git a/codegen/testserver/input_test.go b/codegen/testserver/input_test.go index 851d1f5eecc..5593c4225c3 100644 --- a/codegen/testserver/input_test.go +++ b/codegen/testserver/input_test.go @@ -5,14 +5,14 @@ import ( "testing" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) func TestInput(t *testing.T) { resolvers := &Stub{} - - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})) + c := client.New(srv) t.Run("when function errors on directives", func(t *testing.T) { resolvers.QueryResolver.InputSlice = func(ctx context.Context, arg []string) (b bool, e error) { diff --git a/codegen/testserver/interfaces_test.go b/codegen/testserver/interfaces_test.go index 88c3fe61ee9..05a31dff349 100644 --- a/codegen/testserver/interfaces_test.go +++ b/codegen/testserver/interfaces_test.go @@ -7,7 +7,7 @@ import ( "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) @@ -24,7 +24,7 @@ func TestInterfaces(t *testing.T) { return nil, nil } - srv := handler.GraphQL( + srv := handler.NewDefaultServer( NewExecutableSchema(Config{ Resolvers: resolvers, Directives: DirectiveRoot{ diff --git a/codegen/testserver/introspection_test.go b/codegen/testserver/introspection_test.go index 97178798665..e98dbe93e2a 100644 --- a/codegen/testserver/introspection_test.go +++ b/codegen/testserver/introspection_test.go @@ -6,19 +6,19 @@ import ( "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/introspection" - "github.com/99designs/gqlgen/handler" "github.com/stretchr/testify/require" ) func TestIntrospection(t *testing.T) { - t.Run("disabled", func(t *testing.T) { + t.Run("disabled when creating your own server", func(t *testing.T) { resolvers := &Stub{} - c := client.New(handler.GraphQL( - NewExecutableSchema(Config{Resolvers: resolvers}), - handler.IntrospectionEnabled(false), - )) + srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) + srv.AddTransport(transport.POST{}) + c := client.New(srv) var resp interface{} err := c.Post(introspection.Query, &resp) @@ -28,7 +28,7 @@ func TestIntrospection(t *testing.T) { t.Run("enabled by default", func(t *testing.T) { resolvers := &Stub{} - c := client.New(handler.GraphQL( + c := client.New(handler.NewDefaultServer( NewExecutableSchema(Config{Resolvers: resolvers}), )) @@ -65,14 +65,12 @@ func TestIntrospection(t *testing.T) { t.Run("disabled by middleware", func(t *testing.T) { resolvers := &Stub{} - c := client.New(handler.GraphQL( - NewExecutableSchema(Config{Resolvers: resolvers}), - handler.RequestMiddleware(func(ctx context.Context, next func(ctx context.Context) []byte) []byte { - graphql.GetRequestContext(ctx).DisableIntrospection = true - - return next(ctx) - }), - )) + srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})) + srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + graphql.GetOperationContext(ctx).DisableIntrospection = true + return next(ctx) + }) + c := client.New(srv) var resp interface{} err := c.Post(introspection.Query, &resp) diff --git a/codegen/testserver/maps_test.go b/codegen/testserver/maps_test.go index 20035f8911c..85b964d9eb8 100644 --- a/codegen/testserver/maps_test.go +++ b/codegen/testserver/maps_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) @@ -21,7 +21,7 @@ func TestMaps(t *testing.T) { return in.Map, nil } - c := client.New(handler.GraphQL( + c := client.New(handler.NewDefaultServer( NewExecutableSchema(Config{Resolvers: resolver}), )) t.Run("unset", func(t *testing.T) { diff --git a/codegen/testserver/middleware_test.go b/codegen/testserver/middleware_test.go index ebfd0b217b9..721f4532272 100644 --- a/codegen/testserver/middleware_test.go +++ b/codegen/testserver/middleware_test.go @@ -6,7 +6,7 @@ import ( "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -27,21 +27,23 @@ func TestMiddleware(t *testing.T) { } areMethods := []bool{} - srv := handler.GraphQL( + srv := handler.NewDefaultServer( NewExecutableSchema(Config{Resolvers: resolvers}), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 1))) - }), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 2))) - }), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - areMethods = append(areMethods, graphql.GetResolverContext(ctx).IsMethod) - return next(ctx) - }), ) + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 1))) + }) + + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 2))) + }) + + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + areMethods = append(areMethods, graphql.GetFieldContext(ctx).IsMethod) + return next(ctx) + }) c := client.New(srv) diff --git a/codegen/testserver/modelmethod_test.go b/codegen/testserver/modelmethod_test.go index 6174c15eab5..6455a8cef44 100644 --- a/codegen/testserver/modelmethod_test.go +++ b/codegen/testserver/modelmethod_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) @@ -18,7 +18,7 @@ func TestModelMethods(t *testing.T) { return true, nil } - c := client.New(handler.GraphQL( + c := client.New(handler.NewDefaultServer( NewExecutableSchema(Config{Resolvers: resolver}), )) t.Run("without context", func(t *testing.T) { diff --git a/codegen/testserver/nulls_test.go b/codegen/testserver/nulls_test.go index eac27a9847b..e79eecc283a 100644 --- a/codegen/testserver/nulls_test.go +++ b/codegen/testserver/nulls_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) @@ -22,7 +22,7 @@ func TestNullBubbling(t *testing.T) { return &Error{ID: "E1234"}, nil } - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) t.Run("when function errors on non required field", func(t *testing.T) { var resp struct { diff --git a/codegen/testserver/panics_test.go b/codegen/testserver/panics_test.go index 92319ed4abb..85235864f0a 100644 --- a/codegen/testserver/panics_test.go +++ b/codegen/testserver/panics_test.go @@ -4,10 +4,9 @@ import ( "context" "testing" - "github.com/stretchr/testify/require" - "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/stretchr/testify/require" ) func TestPanics(t *testing.T) { @@ -22,7 +21,7 @@ func TestPanics(t *testing.T) { return []MarshalPanic{MarshalPanic("aa"), MarshalPanic("bb")}, nil } - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) t.Run("panics in marshallers will not kill server", func(t *testing.T) { var resp interface{} diff --git a/codegen/testserver/primitive_objects_test.go b/codegen/testserver/primitive_objects_test.go index cef6a84b2a9..c52a8979d73 100644 --- a/codegen/testserver/primitive_objects_test.go +++ b/codegen/testserver/primitive_objects_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/assert" ) @@ -19,7 +19,7 @@ func TestPrimitiveObjects(t *testing.T) { return int(*obj), nil } - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) t.Run("can fetch value", func(t *testing.T) { var resp struct { @@ -51,7 +51,7 @@ func TestPrimitiveStringObjects(t *testing.T) { return len(string(*obj)), nil } - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) t.Run("can fetch value", func(t *testing.T) { var resp struct { diff --git a/codegen/testserver/response_extension_test.go b/codegen/testserver/response_extension_test.go index 985c7aa09e4..692327d0f2c 100644 --- a/codegen/testserver/response_extension_test.go +++ b/codegen/testserver/response_extension_test.go @@ -6,7 +6,7 @@ import ( "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) @@ -16,16 +16,16 @@ func TestResponseExtension(t *testing.T) { return "Ok", nil } - srv := handler.GraphQL( + srv := handler.NewDefaultServer( NewExecutableSchema(Config{Resolvers: resolvers}), - handler.RequestMiddleware(func(ctx context.Context, next func(ctx context.Context) []byte) []byte { - rctx := graphql.GetRequestContext(ctx) - if err := rctx.RegisterExtension("example", "value"); err != nil { - panic(err) - } - return next(ctx) - }), ) + + srv.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + graphql.RegisterExtension(ctx, "example", "value") + + return next(ctx) + }) + c := client.New(srv) raw, _ := c.RawPost(`query { valid }`) diff --git a/codegen/testserver/scalar_default_test.go b/codegen/testserver/scalar_default_test.go index d891737b787..c510ca46671 100644 --- a/codegen/testserver/scalar_default_test.go +++ b/codegen/testserver/scalar_default_test.go @@ -5,14 +5,14 @@ import ( "testing" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) func TestDefaultScalarImplementation(t *testing.T) { resolvers := &Stub{} - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) resolvers.QueryResolver.DefaultScalar = func(ctx context.Context, arg string) (i string, e error) { return arg, nil diff --git a/codegen/testserver/slices_test.go b/codegen/testserver/slices_test.go index 6d314b71bbf..783a4a49b00 100644 --- a/codegen/testserver/slices_test.go +++ b/codegen/testserver/slices_test.go @@ -5,14 +5,14 @@ import ( "testing" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) func TestSlices(t *testing.T) { resolvers := &Stub{} - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) t.Run("nulls vs empty slices", func(t *testing.T) { resolvers.QueryResolver.Slices = func(ctx context.Context) (slices *Slices, e error) { diff --git a/codegen/testserver/subscription_test.go b/codegen/testserver/subscription_test.go index 9e34599155c..1731aae9b46 100644 --- a/codegen/testserver/subscription_test.go +++ b/codegen/testserver/subscription_test.go @@ -8,9 +8,11 @@ import ( "testing" "time" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) @@ -20,7 +22,7 @@ func TestSubscriptions(t *testing.T) { resolvers := &Stub{} resolvers.SubscriptionResolver.InitPayload = func(ctx context.Context) (strings <-chan string, e error) { - payload := handler.GetInitPayload(ctx) + payload := transport.GetInitPayload(ctx) channel := make(chan string, len(payload)+1) go func() { @@ -66,17 +68,19 @@ func TestSubscriptions(t *testing.T) { return res, nil } - srv := handler.GraphQL( + srv := handler.NewDefaultServer( NewExecutableSchema(Config{Resolvers: resolvers}), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 1))) - }), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 2))) - }), ) + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 1))) + }) + + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 2))) + }) + c := client.New(srv) t.Run("wont leak goroutines", func(t *testing.T) { diff --git a/codegen/testserver/time_test.go b/codegen/testserver/time_test.go index 1b41df3aea2..291567e7a1b 100644 --- a/codegen/testserver/time_test.go +++ b/codegen/testserver/time_test.go @@ -6,14 +6,14 @@ import ( "time" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) func TestTime(t *testing.T) { resolvers := &Stub{} - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) { return &User{}, nil diff --git a/codegen/testserver/tracer_test.go b/codegen/testserver/tracer_test.go deleted file mode 100644 index 07c39b080f5..00000000000 --- a/codegen/testserver/tracer_test.go +++ /dev/null @@ -1,346 +0,0 @@ -package testserver - -import ( - "context" - "fmt" - "sync" - "testing" - - "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/handler" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestTracer(t *testing.T) { - resolvers := &Stub{} - resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) { - return &User{ID: 1}, nil - } - t.Run("called in the correct order", func(t *testing.T) { - var tracerLog []string - var mu sync.Mutex - - srv := handler.GraphQL( - NewExecutableSchema(Config{Resolvers: resolvers}), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 1))) - }), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 2))) - }), - handler.Tracer(&testTracer{ - id: 1, - append: func(s string) { - mu.Lock() - defer mu.Unlock() - tracerLog = append(tracerLog, s) - }, - }), - handler.Tracer(&testTracer{ - id: 2, - append: func(s string) { - mu.Lock() - defer mu.Unlock() - tracerLog = append(tracerLog, s) - }, - }), - ) - c := client.New(srv) - - var resp struct { - User struct { - ID int - Friends []struct { - ID int - } - } - } - - called := false - resolvers.UserResolver.Friends = func(ctx context.Context, obj *User) ([]*User, error) { - assert.Equal(t, []string{ - "op:p:start:1", "op:p:start:2", - "op:v:start:1", "op:v:start:2", - "op:e:start:1", "op:e:start:2", - "field'a:e:start:1:user", "field'a:e:start:2:user", - "field'b:e:start:1:[user]", "field'b:e:start:2:[user]", - "field'c:e:start:1", "field'c:e:start:2", - "field'a:e:start:1:friends", "field'a:e:start:2:friends", - "field'b:e:start:1:[user friends]", "field'b:e:start:2:[user friends]", - }, ctx.Value("tracer")) - called = true - return []*User{}, nil - } - - err := c.Post(`query { user(id: 1) { id, friends { id } } }`, &resp) - - require.NoError(t, err) - require.True(t, called) - mu.Lock() - defer mu.Unlock() - assert.Equal(t, []string{ - "op:p:start:1", "op:p:start:2", - "op:p:end:2", "op:p:end:1", - - "op:v:start:1", "op:v:start:2", - "op:v:end:2", "op:v:end:1", - - "op:e:start:1", "op:e:start:2", - - "field'a:e:start:1:user", "field'a:e:start:2:user", - "field'b:e:start:1:[user]", "field'b:e:start:2:[user]", - "field'c:e:start:1", "field'c:e:start:2", - "field'a:e:start:1:id", "field'a:e:start:2:id", - "field'b:e:start:1:[user id]", "field'b:e:start:2:[user id]", - "field'c:e:start:1", "field'c:e:start:2", - "field:e:end:2", "field:e:end:1", - "field'a:e:start:1:friends", "field'a:e:start:2:friends", - "field'b:e:start:1:[user friends]", "field'b:e:start:2:[user friends]", - "field'c:e:start:1", "field'c:e:start:2", - "field:e:end:2", "field:e:end:1", - "field:e:end:2", "field:e:end:1", - - "op:e:end:2", "op:e:end:1", - }, tracerLog) - }) - - t.Run("take ctx over from prev step", func(t *testing.T) { - - configurableTracer := &configurableTracer{ - StartOperationParsingCallback: func(ctx context.Context) context.Context { - return context.WithValue(ctx, "StartOperationParsing", true) - }, - EndOperationParsingCallback: func(ctx context.Context) { - assert.NotNil(t, ctx.Value("StartOperationParsing")) - }, - - StartOperationValidationCallback: func(ctx context.Context) context.Context { - return context.WithValue(ctx, "StartOperationValidation", true) - }, - EndOperationValidationCallback: func(ctx context.Context) { - assert.NotNil(t, ctx.Value("StartOperationParsing")) - assert.NotNil(t, ctx.Value("StartOperationValidation")) - }, - - StartOperationExecutionCallback: func(ctx context.Context) context.Context { - return context.WithValue(ctx, "StartOperationExecution", true) - }, - StartFieldExecutionCallback: func(ctx context.Context, field graphql.CollectedField) context.Context { - return context.WithValue(ctx, "StartFieldExecution", true) - }, - StartFieldResolverExecutionCallback: func(ctx context.Context, rc *graphql.ResolverContext) context.Context { - return context.WithValue(ctx, "StartFieldResolverExecution", true) - }, - StartFieldChildExecutionCallback: func(ctx context.Context) context.Context { - return context.WithValue(ctx, "StartFieldChildExecution", true) - }, - EndFieldExecutionCallback: func(ctx context.Context) { - assert.NotNil(t, ctx.Value("StartOperationParsing")) - assert.NotNil(t, ctx.Value("StartOperationValidation")) - assert.NotNil(t, ctx.Value("StartOperationExecution")) - assert.NotNil(t, ctx.Value("StartFieldExecution")) - assert.NotNil(t, ctx.Value("StartFieldResolverExecution")) - assert.NotNil(t, ctx.Value("StartFieldChildExecution")) - }, - - EndOperationExecutionCallback: func(ctx context.Context) { - assert.NotNil(t, ctx.Value("StartOperationParsing")) - assert.NotNil(t, ctx.Value("StartOperationValidation")) - assert.NotNil(t, ctx.Value("StartOperationExecution")) - }, - } - - c := client.New(handler.GraphQL( - NewExecutableSchema(Config{Resolvers: resolvers}), - handler.Tracer(configurableTracer), - )) - - var resp struct { - User struct { - ID int - Friends []struct { - ID int - } - } - } - - called := false - resolvers.UserResolver.Friends = func(ctx context.Context, obj *User) ([]*User, error) { - called = true - return []*User{}, nil - } - - err := c.Post(`query { user(id: 1) { id, friends { id } } }`, &resp) - - require.NoError(t, err) - require.True(t, called) - }) -} - -var _ graphql.Tracer = (*configurableTracer)(nil) - -type configurableTracer struct { - StartOperationParsingCallback func(ctx context.Context) context.Context - EndOperationParsingCallback func(ctx context.Context) - StartOperationValidationCallback func(ctx context.Context) context.Context - EndOperationValidationCallback func(ctx context.Context) - StartOperationExecutionCallback func(ctx context.Context) context.Context - StartFieldExecutionCallback func(ctx context.Context, field graphql.CollectedField) context.Context - StartFieldResolverExecutionCallback func(ctx context.Context, rc *graphql.ResolverContext) context.Context - StartFieldChildExecutionCallback func(ctx context.Context) context.Context - EndFieldExecutionCallback func(ctx context.Context) - EndOperationExecutionCallback func(ctx context.Context) -} - -func (ct *configurableTracer) StartOperationParsing(ctx context.Context) context.Context { - if f := ct.StartOperationParsingCallback; f != nil { - ctx = f(ctx) - } - return ctx -} - -func (ct *configurableTracer) EndOperationParsing(ctx context.Context) { - if f := ct.EndOperationParsingCallback; f != nil { - f(ctx) - } -} - -func (ct *configurableTracer) StartOperationValidation(ctx context.Context) context.Context { - if f := ct.StartOperationValidationCallback; f != nil { - ctx = f(ctx) - } - return ctx -} - -func (ct *configurableTracer) EndOperationValidation(ctx context.Context) { - if f := ct.EndOperationValidationCallback; f != nil { - f(ctx) - } -} - -func (ct *configurableTracer) StartOperationExecution(ctx context.Context) context.Context { - if f := ct.StartOperationExecutionCallback; f != nil { - ctx = f(ctx) - } - return ctx -} - -func (ct *configurableTracer) StartFieldExecution(ctx context.Context, field graphql.CollectedField) context.Context { - if f := ct.StartFieldExecutionCallback; f != nil { - ctx = f(ctx, field) - } - return ctx -} - -func (ct *configurableTracer) StartFieldResolverExecution(ctx context.Context, rc *graphql.ResolverContext) context.Context { - if f := ct.StartFieldResolverExecutionCallback; f != nil { - ctx = f(ctx, rc) - } - return ctx -} - -func (ct *configurableTracer) StartFieldChildExecution(ctx context.Context) context.Context { - if f := ct.StartFieldChildExecutionCallback; f != nil { - ctx = f(ctx) - } - return ctx -} - -func (ct *configurableTracer) EndFieldExecution(ctx context.Context) { - if f := ct.EndFieldExecutionCallback; f != nil { - f(ctx) - } -} - -func (ct *configurableTracer) EndOperationExecution(ctx context.Context) { - if f := ct.EndOperationExecutionCallback; f != nil { - f(ctx) - } -} - -var _ graphql.Tracer = (*testTracer)(nil) - -type testTracer struct { - id int - append func(string) -} - -func (tt *testTracer) StartOperationParsing(ctx context.Context) context.Context { - line := fmt.Sprintf("op:p:start:%d", tt.id) - - tracerLogs, _ := ctx.Value("tracer").([]string) - ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) - tt.append(line) - - return ctx -} - -func (tt *testTracer) EndOperationParsing(ctx context.Context) { - tt.append(fmt.Sprintf("op:p:end:%d", tt.id)) -} - -func (tt *testTracer) StartOperationValidation(ctx context.Context) context.Context { - line := fmt.Sprintf("op:v:start:%d", tt.id) - - tracerLogs, _ := ctx.Value("tracer").([]string) - ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) - tt.append(line) - - return ctx -} - -func (tt *testTracer) EndOperationValidation(ctx context.Context) { - tt.append(fmt.Sprintf("op:v:end:%d", tt.id)) -} - -func (tt *testTracer) StartOperationExecution(ctx context.Context) context.Context { - line := fmt.Sprintf("op:e:start:%d", tt.id) - - tracerLogs, _ := ctx.Value("tracer").([]string) - ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) - tt.append(line) - - return ctx -} - -func (tt *testTracer) StartFieldExecution(ctx context.Context, field graphql.CollectedField) context.Context { - line := fmt.Sprintf("field'a:e:start:%d:%s", tt.id, field.Name) - - tracerLogs, _ := ctx.Value("tracer").([]string) - ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) - tt.append(line) - - return ctx -} - -func (tt *testTracer) StartFieldResolverExecution(ctx context.Context, rc *graphql.ResolverContext) context.Context { - line := fmt.Sprintf("field'b:e:start:%d:%v", tt.id, rc.Path()) - - tracerLogs, _ := ctx.Value("tracer").([]string) - ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) - tt.append(line) - - return ctx -} - -func (tt *testTracer) StartFieldChildExecution(ctx context.Context) context.Context { - line := fmt.Sprintf("field'c:e:start:%d", tt.id) - - tracerLogs, _ := ctx.Value("tracer").([]string) - ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) - tt.append(line) - - return ctx -} - -func (tt *testTracer) EndFieldExecution(ctx context.Context) { - tt.append(fmt.Sprintf("field:e:end:%d", tt.id)) -} - -func (tt *testTracer) EndOperationExecution(ctx context.Context) { - tt.append(fmt.Sprintf("op:e:end:%d", tt.id)) -} diff --git a/codegen/testserver/typefallback_test.go b/codegen/testserver/typefallback_test.go index ac74f36ac7c..8ebd091e9ef 100644 --- a/codegen/testserver/typefallback_test.go +++ b/codegen/testserver/typefallback_test.go @@ -5,14 +5,14 @@ import ( "testing" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) func TestTypeFallback(t *testing.T) { resolvers := &Stub{} - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) resolvers.QueryResolver.Fallback = func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { return arg, nil diff --git a/codegen/testserver/validtypes_test.go b/codegen/testserver/validtypes_test.go index 412ebbe41dc..6ae9f1bff1c 100644 --- a/codegen/testserver/validtypes_test.go +++ b/codegen/testserver/validtypes_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) @@ -18,7 +18,7 @@ func TestValidType(t *testing.T) { }, nil } - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) t.Run("fields with differing cases can be distinguished", func(t *testing.T) { var resp struct { diff --git a/codegen/testserver/wrapped_type_test.go b/codegen/testserver/wrapped_type_test.go index 4785307f2b0..7c0405a1149 100644 --- a/codegen/testserver/wrapped_type_test.go +++ b/codegen/testserver/wrapped_type_test.go @@ -6,14 +6,14 @@ import ( "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/codegen/testserver/otherpkg" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) func TestWrappedTypes(t *testing.T) { resolvers := &Stub{} - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) resolvers.QueryResolver.WrappedScalar = func(ctx context.Context) (scalar WrappedScalar, e error) { return "hello", nil diff --git a/codegen/type.gotpl b/codegen/type.gotpl index cb2782c39ed..dad8a8d9984 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -50,7 +50,7 @@ {{- if $type.IsNilable }} if v == nil { {{- if $type.GQL.NonNull }} - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } {{- end }} @@ -75,11 +75,11 @@ for i := range v { {{- if not $type.IsScalar }} i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -113,7 +113,7 @@ {{- else if $type.GQL.NonNull }} res := {{ $type.Marshaler | call }}({{- if $type.CastType }}{{ $type.CastType | ref }}(v){{else}}v{{- end }}) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } diff --git a/complexity/complexity_test.go b/complexity/complexity_test.go index 93b61980992..a7a2f25565b 100644 --- a/complexity/complexity_test.go +++ b/complexity/complexity_test.go @@ -1,7 +1,6 @@ package complexity import ( - "context" "math" "testing" @@ -50,7 +49,24 @@ var schema = gqlparser.MustLoadSchema( func requireComplexity(t *testing.T, source string, complexity int) { t.Helper() query := gqlparser.MustLoadQuery(schema, source) - es := &executableSchemaStub{} + + es := &graphql.ExecutableSchemaMock{ + ComplexityFunc: func(typeName, field string, childComplexity int, args map[string]interface{}) (int, bool) { + switch typeName + "." + field { + case "ExpensiveItem.name": + return 5, true + case "Query.list", "Item.list": + return int(args["size"].(int64)) * childComplexity, true + case "Query.customObject": + return 1, true + } + return 0, false + }, + SchemaFunc: func() *ast.Schema { + return schema + }, + } + actualComplexity := Calculate(es, query.Operations[0], nil) require.Equal(t, complexity, actualComplexity) } @@ -197,36 +213,3 @@ func TestCalculate(t *testing.T) { requireComplexity(t, query, math.MaxInt64) }) } - -type executableSchemaStub struct { -} - -var _ graphql.ExecutableSchema = &executableSchemaStub{} - -func (e *executableSchemaStub) Schema() *ast.Schema { - return schema -} - -func (e *executableSchemaStub) Complexity(typeName, field string, childComplexity int, args map[string]interface{}) (int, bool) { - switch typeName + "." + field { - case "ExpensiveItem.name": - return 5, true - case "Query.list", "Item.list": - return int(args["size"].(int64)) * childComplexity, true - case "Query.customObject": - return 1, true - } - return 0, false -} - -func (e *executableSchemaStub) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - panic("Query should never be called by complexity calculations") -} - -func (e *executableSchemaStub) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - panic("Mutation should never be called by complexity calculations") -} - -func (e *executableSchemaStub) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - panic("Subscription should never be called by complexity calculations") -} diff --git a/docs/content/recipes/authentication.md b/docs/content/recipes/authentication.md index 284330a9c08..a1c7d24cda3 100644 --- a/docs/content/recipes/authentication.md +++ b/docs/content/recipes/authentication.md @@ -78,7 +78,8 @@ import ( "net/http" "github.com/99designs/gqlgen/example/starwars" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/playground" "github.com/go-chi/chi" ) @@ -87,10 +88,9 @@ func main() { router.Use(auth.Middleware(db)) - router.Handle("/", handler.Playground("Starwars", "/query")) - router.Handle("/query", - handler.GraphQL(starwars.NewExecutableSchema(starwars.NewResolver())), - ) + srv := handler.NewDefaultServer(starwars.NewExecutableSchema(starwars.NewResolver())) + router.Handle("/", playground.Handler("Starwars", "/query")) + router.Handle("/query", srv) err := http.ListenAndServe(":8080", router) if err != nil { diff --git a/docs/content/recipes/cors.md b/docs/content/recipes/cors.md index 321c49b89c9..cbfaa2576d3 100644 --- a/docs/content/recipes/cors.md +++ b/docs/content/recipes/cors.md @@ -15,10 +15,11 @@ gqlgen doesn't include a CORS implementation, but it is built to work with all s package main import ( - "net/http" + "net/http" - "github.com/99designs/gqlgen/example/starwars" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/99designs/gqlgen/example/starwars" + "github.com/99designs/gqlgen/graphql/handler" "github.com/go-chi/chi" "github.com/rs/cors" ) @@ -34,19 +35,21 @@ func main() { Debug: true, }).Handler) - upgrader := websocket.Upgrader{ - CheckOrigin: func(r *http.Request) bool { - // Check against your desired domains here - return r.Host == "example.org" - }, - ReadBufferSize: 1024, - WriteBufferSize: 1024, - } + + srv := handler.New(starwars.NewExecutableSchema(starwars.NewResolver())) + srv.AddTransport(&transport.Websocket{ + Upgrader: websocket.Upgrader{ + CheckOrigin: func(r *http.Request) bool { + // Check against your desired domains here + return r.Host == "example.org" + }, + ReadBufferSize: 1024, + WriteBufferSize: 1024, + }, + }) router.Handle("/", handler.Playground("Starwars", "/query")) - router.Handle("/query", - handler.GraphQL(starwars.NewExecutableSchema(starwars.NewResolver()), handler.WebsocketUpgrader(upgrader)), - ) + router.Handle("/query", srv) err := http.ListenAndServe(":8080", router) if err != nil { diff --git a/docs/content/recipes/gin.md b/docs/content/recipes/gin.md index e793575031c..1e680dc6471 100644 --- a/docs/content/recipes/gin.md +++ b/docs/content/recipes/gin.md @@ -19,7 +19,7 @@ $ go get github.com/gin-gonic/gin In your router file, define the handlers for the GraphQL and Playground endpoints in two different methods and tie then together in the Gin router: ```go import ( - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/gin-gonic/gin" ) @@ -27,7 +27,7 @@ import ( func graphqlHandler() gin.HandlerFunc { // NewExecutableSchema and Config are in the generated.go file // Resolver is in the resolver.go file - h := handler.GraphQL(NewExecutableSchema(Config{Resolvers: &Resolver{}})) + h := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{}})) return func(c *gin.Context) { h.ServeHTTP(c.Writer, c.Request) @@ -36,7 +36,7 @@ func graphqlHandler() gin.HandlerFunc { // Defining the Playground handler func playgroundHandler() gin.HandlerFunc { - h := handler.Playground("GraphQL", "/query") + h := playground.Handler("GraphQL", "/query") return func(c *gin.Context) { h.ServeHTTP(c.Writer, c.Request) @@ -99,4 +99,4 @@ func (r *resolver) Todo(ctx context.Context) (*Todo, error) { // ... } -``` \ No newline at end of file +``` diff --git a/docs/content/recipes/migration-0.11.md b/docs/content/recipes/migration-0.11.md new file mode 100644 index 00000000000..5b82f1bef2c --- /dev/null +++ b/docs/content/recipes/migration-0.11.md @@ -0,0 +1,110 @@ +--- +title: "Migrating to 0.11" +description: Using the new graphql/handler package in gqlgen 0.11 +linkTitle: Migrating to 0.11 +menu: { main: { parent: 'recipes' } } +--- + +The handler package has grown organically for a long time, 0.11 is a large cleanup of the handler package to make it +more modular and easier to maintain once we get to 1.0. + + +### Transports + +Transports are the first thing that run, they handle decoding the incoming http request, and encoding the graphql +response. Supported transports are: + - GET + - JSON POST + - Multipart form + - Websockets + +new usage looks like this +```go +srv := New(es) + +srv.AddTransport(transport.Websocket{ + KeepAlivePingInterval: 10 * time.Second, +}) +srv.AddTransport(transport.Options{}) +srv.AddTransport(transport.GET{}) +srv.AddTransport(transport.POST{}) +srv.AddTransport(transport.MultipartForm{}) +```` + + +### New handler extension API + +The core of this changes the handler package to be a set of composable extensions. The extensions implement a set of optional interfaces: +- **OperationParameterMutator** runs before creating a OperationContext (formerly RequestContext). allows manipulating the raw query before parsing. +- **OperationContextMutator** runs after creating the OperationContext, but before executing the root resolver. +- **OperationInterceptor** runs for each incoming query after parsing and validation, for basic requests the writer will be invoked once, for subscriptions it will be invoked multiple times. +- **ResponseInterceptor** runs around each graphql operation response. This can be called many times for a single operation the case of subscriptions. +- **FieldInterceptor** runs around each field + +![Anatomy of a request@2x](https://user-images.githubusercontent.com/2247982/68181515-c8a27c00-ffeb-11e9-86f6-1673e7179ecb.png) + +Users of an extension should not need to know which extension points are being used by a given extension, they are added to the server simply by calling `Use(extension)`. + +There are a few convenience methods for defining middleware inline, instead of creating an extension +```go +srv := handler.New(es) +srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + // this function will be called around every field. next() will evaluate the field and return + // its computed value. + return next(ctx) +}) +srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + // This function will be called around every operation, next() will return a function that when + // called will evaluate one response. Eventually next will return nil, signalling there are no + // more results to be returned by the server. + return next(ctx) +}) +srv.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + // This function will be called around each response in the operation. next() will evaluate + // and return a single response. + return next(ctx) +}) +``` + + +Some of the features supported out of the box by handler extensions: + - APQ + - Query Complexity + - Error Presenters and Recover Func + - Introspection Query support + - Query AST cache + - Tracing API + +They can be `Use`'d like this: +```go +srv := handler.New(es) +srv.Use(extension.Introspection{}) +srv.Use(extension.AutomaticPersistedQuery{ + Cache: lru.New(100), +}) +srv.Use(apollotracing.Tracer{}) +``` + +### Default server + +We provide a set of default extensions and transports if you aren't ready to customize them yet. Simply: +```go +handler.NewDefaultServer(es) +``` + +### More contesistent naming + +As part of cleaning up the names the RequestContext has been renamed to OperationContext, as there can be multiple created during the lifecycle of a request. A new ResponseContext has also been created and error handling has been moved here. This allows each response in a subscription to have its own errors. I'm not sure what bugs this might have been causing before... + +### Removal of tracing + +Many of the old interfaces collapse down into just a few extension points: +![Anatomy of a request@2x (1)](https://user-images.githubusercontent.com/2247982/68181517-cb04d600-ffeb-11e9-9271-0295e6c4ff34.png) + +The tracing interface has also been removed, tracing stats are now measured in core (eg time to parse query) and made available on the operation/response contexts. Much of the old interface was designed so that users of a tracer dont need to know which extension points it was listening to, the new handler extensions have the same goal. + +### Backward compatibility + +There is a backwards compatibility layer that keeps most of the original interface in place. There are a few places where BC is known to be broken: + - ResponseMiddleware: The signature used to be `func(ctx context.Context, next func(ctx context.Context) []byte) []byte` and is now `func(ctx context.Context) *Response`. We could maintain BC by marshalling to json before and after, but the change is pretty easy to make and is likely to cause less issues. + - The Tracer interface has been removed, any tracers will need to be reimplemented against the new extension interface. diff --git a/docs/content/reference/introspection.md b/docs/content/reference/introspection.md index b2460106786..f9c8cc9d2b8 100644 --- a/docs/content/reference/introspection.md +++ b/docs/content/reference/introspection.md @@ -30,7 +30,7 @@ srv := httptest.NewServer( NewExecutableSchema(Config{Resolvers: resolvers}), handler.RequestMiddleware(func(ctx context.Context, next func(ctx context.Context) []byte) []byte { if !userForContext(ctx).IsAdmin { - graphql.GetRequestContext(ctx).DisableIntrospection = true + graphql.GetOperationContext(ctx).DisableIntrospection = true } return next(ctx) diff --git a/docs/static/main.css b/docs/static/main.css index 0e26e83a766..4a13c4e8954 100644 --- a/docs/static/main.css +++ b/docs/static/main.css @@ -84,6 +84,10 @@ a { text-decoration: none; } +img { + max-width: 100%; +} + a:hover { text-decoration: underline; } diff --git a/example/chat/chat_test.go b/example/chat/chat_test.go index c3eff1832f5..40b37c07f70 100644 --- a/example/chat/chat_test.go +++ b/example/chat/chat_test.go @@ -5,13 +5,13 @@ import ( "time" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestChatSubscriptions(t *testing.T) { - c := client.New(handler.GraphQL(NewExecutableSchema(New()))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(New()))) sub := c.Websocket(`subscription @user(username:"vektah") { messageAdded(roomName:"#gophers") { text createdBy } }`) defer sub.Close() diff --git a/example/chat/generated.go b/example/chat/generated.go index 1f4144fd45b..2b421dd96cb 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -177,53 +177,47 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._Query(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} + return &graphql.Response{ + Data: buf.Bytes(), + } + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._Mutation(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} + return &graphql.Response{ + Data: buf.Bytes(), + } + } + case ast.Subscription: + next := ec._subscriptionMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error) { + return ec._Subscription(ctx, rc.Operation.SelectionSet), nil + }) - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Mutation(ctx, op.SelectionSet) var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - next := ec._subscriptionMiddleware(ctx, op, func(ctx context.Context) (interface{}, error) { - return ec._Subscription(ctx, op.SelectionSet), nil - }) - if ec.Errors != nil { - return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) - } - - var buf bytes.Buffer - return func() *graphql.Response { - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + return func(ctx context.Context) *graphql.Response { buf.Reset() data := next() @@ -231,23 +225,19 @@ func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDe return nil } data.MarshalGQL(&buf) - return buf.Bytes() - }) - if buf == nil { - return nil + return &graphql.Response{ + Data: buf.Bytes(), + } } - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { - *graphql.RequestContext + *graphql.OperationContext *executableSchema } @@ -460,22 +450,20 @@ func (ec *executionContext) _subscriptionMiddleware(ctx context.Context, obj *as // region **************************** field.gotpl ***************************** func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.CollectedField, obj *Chatroom) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Chatroom", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -485,34 +473,31 @@ func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphql.CollectedField, obj *Chatroom) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Chatroom", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Messages, nil @@ -522,34 +507,31 @@ func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]Message) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessageᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Message_id(ctx context.Context, field graphql.CollectedField, obj *Message) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Message", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -559,34 +541,31 @@ func (ec *executionContext) _Message_id(ctx context.Context, field graphql.Colle return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Message_text(ctx context.Context, field graphql.CollectedField, obj *Message) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Message", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Text, nil @@ -596,34 +575,31 @@ func (ec *executionContext) _Message_text(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphql.CollectedField, obj *Message) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Message", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.CreatedBy, nil @@ -633,34 +609,31 @@ func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphql.CollectedField, obj *Message) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Message", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.CreatedAt, nil @@ -670,41 +643,38 @@ func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(time.Time) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_post_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().Post(rctx, args["text"].(string), args["username"].(string), args["roomName"].(string)) @@ -714,41 +684,38 @@ func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*Message) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNMessage2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res) } func (ec *executionContext) _Query_room(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_room_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Room(rctx, args["name"].(string)) @@ -761,35 +728,32 @@ func (ec *executionContext) _Query_room(ctx context.Context, field graphql.Colle return graphql.Null } res := resTmp.(*Chatroom) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) @@ -802,28 +766,25 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() @@ -836,35 +797,32 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, field graphql.CollectedField) (ret func() graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Subscription", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Subscription_messageAdded_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return nil } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Subscription().MessageAdded(rctx, args["roomName"].(string)) @@ -874,7 +832,7 @@ func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, fiel return nil } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return nil @@ -895,22 +853,20 @@ func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, fiel } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -920,34 +876,31 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -960,28 +913,25 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil @@ -991,34 +941,31 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -1028,34 +975,31 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1065,34 +1009,31 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1105,28 +1046,25 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -1136,34 +1074,31 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1176,28 +1111,25 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1207,34 +1139,31 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1247,28 +1176,25 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -1278,34 +1204,31 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1315,34 +1238,31 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -1352,34 +1272,31 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1392,28 +1309,25 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1423,34 +1337,31 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1463,28 +1374,25 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1494,34 +1402,31 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil @@ -1534,28 +1439,25 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil @@ -1565,34 +1467,31 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil @@ -1602,34 +1501,31 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil @@ -1642,28 +1538,25 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil @@ -1676,28 +1569,25 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil @@ -1707,34 +1597,31 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil @@ -1744,34 +1631,31 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil @@ -1784,28 +1668,25 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -1818,35 +1699,32 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil @@ -1859,28 +1737,25 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil @@ -1893,28 +1768,25 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil @@ -1927,35 +1799,32 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil @@ -1968,28 +1837,25 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil @@ -2002,28 +1868,25 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil @@ -2036,8 +1899,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } @@ -2056,7 +1918,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co var chatroomImplementors = []string{"Chatroom"} func (ec *executionContext) _Chatroom(ctx context.Context, sel ast.SelectionSet, obj *Chatroom) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, chatroomImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, chatroomImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2088,7 +1950,7 @@ func (ec *executionContext) _Chatroom(ctx context.Context, sel ast.SelectionSet, var messageImplementors = []string{"Message"} func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet, obj *Message) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, messageImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, messageImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2130,9 +1992,9 @@ func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet, var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, mutationImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Mutation", }) @@ -2161,9 +2023,9 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, queryImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) @@ -2202,8 +2064,8 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var subscriptionImplementors = []string{"Subscription"} func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, subscriptionImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + fields := graphql.CollectFields(ec.OperationContext, sel, subscriptionImplementors) + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Subscription", }) if len(fields) != 1 { @@ -2222,7 +2084,7 @@ func (ec *executionContext) _Subscription(ctx context.Context, sel ast.Selection var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2261,7 +2123,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2297,7 +2159,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __FieldImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2343,7 +2205,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __InputValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2379,7 +2241,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __SchemaImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2420,7 +2282,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __TypeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2471,7 +2333,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2485,7 +2347,7 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalID(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2505,11 +2367,11 @@ func (ec *executionContext) marshalNMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2535,7 +2397,7 @@ func (ec *executionContext) marshalNMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalNMessage2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v *Message) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2550,7 +2412,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2564,7 +2426,7 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { res := graphql.MarshalTime(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2584,11 +2446,11 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2619,7 +2481,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2655,11 +2517,11 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2704,11 +2566,11 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2745,11 +2607,11 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2775,7 +2637,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2790,7 +2652,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2866,11 +2728,11 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2906,11 +2768,11 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2946,11 +2808,11 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3001,11 +2863,11 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { diff --git a/example/chat/server/server.go b/example/chat/server/server.go index 0bcee178723..65077b80e8a 100644 --- a/example/chat/server/server.go +++ b/example/chat/server/server.go @@ -6,8 +6,13 @@ import ( "net/url" "time" + "github.com/99designs/gqlgen/graphql/handler/extension" + "github.com/99designs/gqlgen/graphql/handler/transport" + + "github.com/99designs/gqlgen/graphql/playground" + "github.com/99designs/gqlgen/example/chat" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/gorilla/websocket" "github.com/opentracing/opentracing-go" "github.com/rs/cors" @@ -24,14 +29,21 @@ func main() { AllowCredentials: true, }) - http.Handle("/", handler.Playground("Todo", "/query")) - http.Handle("/query", c.Handler(handler.GraphQL(chat.NewExecutableSchema(chat.New()), - handler.WebsocketUpgrader(websocket.Upgrader{ + srv := handler.New(chat.NewExecutableSchema(chat.New())) + + srv.AddTransport(transport.Websocket{ + KeepAlivePingInterval: 10 * time.Second, + Upgrader: websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { return true }, - }))), - ) + }, + }) + srv.Use(extension.Introspection{}) + + http.Handle("/", playground.Handler("Todo", "/query")) + http.Handle("/query", c.Handler(srv)) + log.Fatal(http.ListenAndServe(":8085", nil)) } diff --git a/example/config/generated.go b/example/config/generated.go index 62669dafe17..fe335b4e717 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -162,46 +162,48 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._Query(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} + return &graphql.Response{ + Data: buf.Bytes(), + } + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._Mutation(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Mutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) + return &graphql.Response{ + Data: buf.Bytes(), + } + } - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - type executionContext struct { - *graphql.RequestContext + *graphql.OperationContext *executableSchema } @@ -322,29 +324,27 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_createTodo_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().CreateTodo(rctx, args["input"].(NewTodo)) @@ -354,34 +354,31 @@ func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field grap return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Todos(rctx) @@ -391,41 +388,38 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) @@ -438,28 +432,25 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() @@ -472,28 +463,25 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Todo", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Todo().ID(rctx, obj) @@ -503,34 +491,31 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Todo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DatabaseID, nil @@ -540,34 +525,31 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Todo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -577,34 +559,31 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Todo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Done, nil @@ -614,34 +593,31 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Todo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.User, nil @@ -651,34 +627,31 @@ func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -688,34 +661,31 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.FullName(), nil @@ -725,34 +695,31 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -762,34 +729,31 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -802,28 +766,25 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil @@ -833,34 +794,31 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -870,34 +828,31 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -907,34 +862,31 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -947,28 +899,25 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -978,34 +927,31 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1018,28 +964,25 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1049,34 +992,31 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1089,28 +1029,25 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -1120,34 +1057,31 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1157,34 +1091,31 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -1194,34 +1125,31 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1234,28 +1162,25 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1265,34 +1190,31 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1305,28 +1227,25 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1336,34 +1255,31 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil @@ -1376,28 +1292,25 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil @@ -1407,34 +1320,31 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil @@ -1444,34 +1354,31 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil @@ -1484,28 +1391,25 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil @@ -1518,28 +1422,25 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil @@ -1549,34 +1450,31 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil @@ -1586,34 +1484,31 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil @@ -1626,28 +1521,25 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -1660,35 +1552,32 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil @@ -1701,28 +1590,25 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil @@ -1735,28 +1621,25 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil @@ -1769,35 +1652,32 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil @@ -1810,28 +1690,25 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil @@ -1844,28 +1721,25 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil @@ -1878,8 +1752,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } @@ -1922,9 +1795,9 @@ func (ec *executionContext) unmarshalInputNewTodo(ctx context.Context, obj inter var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, mutationImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Mutation", }) @@ -1953,9 +1826,9 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, queryImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) @@ -1997,7 +1870,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var todoImplementors = []string{"Todo"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, todoImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2053,7 +1926,7 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj var userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, userImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2085,7 +1958,7 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2124,7 +1997,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2160,7 +2033,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __FieldImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2206,7 +2079,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __InputValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2242,7 +2115,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __SchemaImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2283,7 +2156,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __TypeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2334,7 +2207,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2348,7 +2221,7 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalID(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2362,7 +2235,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalInt(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2380,7 +2253,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2400,11 +2273,11 @@ func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2430,7 +2303,7 @@ func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2444,7 +2317,7 @@ func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋexa func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2465,11 +2338,11 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2500,7 +2373,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2536,11 +2409,11 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2585,11 +2458,11 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2626,11 +2499,11 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2656,7 +2529,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2671,7 +2544,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2768,11 +2641,11 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2808,11 +2681,11 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2848,11 +2721,11 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2903,11 +2776,11 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { diff --git a/example/config/server/server.go b/example/config/server/server.go index 7ff1b8c8044..b2dfbeda73e 100644 --- a/example/config/server/server.go +++ b/example/config/server/server.go @@ -5,12 +5,13 @@ import ( "net/http" todo "github.com/99designs/gqlgen/example/config" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/playground" ) func main() { - http.Handle("/", handler.Playground("Todo", "/query")) - http.Handle("/query", handler.GraphQL( + http.Handle("/", playground.Handler("Todo", "/query")) + http.Handle("/query", handler.NewDefaultServer( todo.NewExecutableSchema(todo.New()), )) log.Fatal(http.ListenAndServe(":8081", nil)) diff --git a/example/dataloader/dataloader_test.go b/example/dataloader/dataloader_test.go index ef20367ad31..17df8076027 100644 --- a/example/dataloader/dataloader_test.go +++ b/example/dataloader/dataloader_test.go @@ -4,13 +4,13 @@ import ( "testing" "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/introspection" - "github.com/99designs/gqlgen/handler" "github.com/stretchr/testify/require" ) func TestTodo(t *testing.T) { - c := client.New(LoaderMiddleware(handler.GraphQL(NewExecutableSchema(Config{Resolvers: &Resolver{}})))) + c := client.New(LoaderMiddleware(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{}})))) t.Run("create a new todo", func(t *testing.T) { var resp interface{} diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index d9c28804d5a..ef8cd9b9eee 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -222,33 +222,34 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._Query(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} + return &graphql.Response{ + Data: buf.Bytes(), + } + } -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } } type executionContext struct { - *graphql.RequestContext + *graphql.OperationContext *executableSchema } @@ -385,22 +386,20 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** func (ec *executionContext) _Address_id(ctx context.Context, field graphql.CollectedField, obj *Address) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Address", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -410,34 +409,31 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Address_street(ctx context.Context, field graphql.CollectedField, obj *Address) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Address", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Street, nil @@ -447,34 +443,31 @@ func (ec *executionContext) _Address_street(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Address_country(ctx context.Context, field graphql.CollectedField, obj *Address) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Address", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Country, nil @@ -484,34 +477,31 @@ func (ec *executionContext) _Address_country(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.CollectedField, obj *Customer) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Customer", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -521,34 +511,31 @@ func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.CollectedField, obj *Customer) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Customer", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -558,34 +545,31 @@ func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Customer_address(ctx context.Context, field graphql.CollectedField, obj *Customer) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Customer", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Customer().Address(rctx, obj) @@ -598,28 +582,25 @@ func (ec *executionContext) _Customer_address(ctx context.Context, field graphql return graphql.Null } res := resTmp.(*Address) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOAddress2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx, field.Selections, res) } func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql.CollectedField, obj *Customer) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Customer", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Customer().Orders(rctx, obj) @@ -632,28 +613,25 @@ func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql. return graphql.Null } res := resTmp.([]*Order) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOOrder2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrderᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Item_name(ctx context.Context, field graphql.CollectedField, obj *Item) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Item", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -663,34 +641,31 @@ func (ec *executionContext) _Item_name(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Order_id(ctx context.Context, field graphql.CollectedField, obj *Order) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Order", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -700,34 +675,31 @@ func (ec *executionContext) _Order_id(ctx context.Context, field graphql.Collect return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Order_date(ctx context.Context, field graphql.CollectedField, obj *Order) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Order", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Date, nil @@ -737,34 +709,31 @@ func (ec *executionContext) _Order_date(ctx context.Context, field graphql.Colle return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(time.Time) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.CollectedField, obj *Order) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Order", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Amount, nil @@ -774,34 +743,31 @@ func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Order_items(ctx context.Context, field graphql.CollectedField, obj *Order) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Order", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Order().Items(rctx, obj) @@ -814,28 +780,25 @@ func (ec *executionContext) _Order_items(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.([]*Item) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOItem2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItemᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_customers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Customers(rctx) @@ -848,35 +811,32 @@ func (ec *executionContext) _Query_customers(ctx context.Context, field graphql. return graphql.Null } res := resTmp.([]*Customer) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOCustomer2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomerᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_torture1d_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Torture1d(rctx, args["customerIds"].([]int)) @@ -889,35 +849,32 @@ func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql. return graphql.Null } res := resTmp.([]*Customer) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOCustomer2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomerᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_torture2d_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Torture2d(rctx, args["customerIds"].([][]int)) @@ -930,35 +887,32 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. return graphql.Null } res := resTmp.([][]*Customer) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOCustomer2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) @@ -971,28 +925,25 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() @@ -1005,28 +956,25 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1036,34 +984,31 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1076,28 +1021,25 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil @@ -1107,34 +1049,31 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -1144,34 +1083,31 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1181,34 +1117,31 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1221,28 +1154,25 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -1252,34 +1182,31 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1292,28 +1219,25 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1323,34 +1247,31 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1363,28 +1284,25 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -1394,34 +1312,31 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1431,34 +1346,31 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -1468,34 +1380,31 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1508,28 +1417,25 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1539,34 +1445,31 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1579,28 +1482,25 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1610,34 +1510,31 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil @@ -1650,28 +1547,25 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil @@ -1681,34 +1575,31 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil @@ -1718,34 +1609,31 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil @@ -1758,28 +1646,25 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil @@ -1792,28 +1677,25 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil @@ -1823,34 +1705,31 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil @@ -1860,34 +1739,31 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil @@ -1900,28 +1776,25 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -1934,35 +1807,32 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil @@ -1975,28 +1845,25 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil @@ -2009,28 +1876,25 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil @@ -2043,35 +1907,32 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil @@ -2084,28 +1945,25 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil @@ -2118,28 +1976,25 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil @@ -2152,8 +2007,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } @@ -2172,7 +2026,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co var addressImplementors = []string{"Address"} func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *Address) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, addressImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, addressImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2209,7 +2063,7 @@ func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, var customerImplementors = []string{"Customer"} func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, obj *Customer) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, customerImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, customerImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2263,7 +2117,7 @@ func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, var itemImplementors = []string{"Item"} func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj *Item) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, itemImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, itemImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2290,7 +2144,7 @@ func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj var orderImplementors = []string{"Order"} func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, obj *Order) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, orderImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, orderImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2338,9 +2192,9 @@ func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, ob var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, queryImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) @@ -2401,7 +2255,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2440,7 +2294,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2476,7 +2330,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __FieldImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2522,7 +2376,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __InputValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2558,7 +2412,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __SchemaImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2599,7 +2453,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __TypeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2650,7 +2504,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2663,7 +2517,7 @@ func (ec *executionContext) marshalNCustomer2githubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalNCustomer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v *Customer) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2678,7 +2532,7 @@ func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v inter func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { res := graphql.MarshalFloat(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2692,7 +2546,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalInt(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2705,7 +2559,7 @@ func (ec *executionContext) marshalNItem2githubᚗcomᚋ99designsᚋgqlgenᚋexa func (ec *executionContext) marshalNItem2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v *Item) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2719,7 +2573,7 @@ func (ec *executionContext) marshalNOrder2githubᚗcomᚋ99designsᚋgqlgenᚋex func (ec *executionContext) marshalNOrder2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v *Order) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2734,7 +2588,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2748,7 +2602,7 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { res := graphql.MarshalTime(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2768,11 +2622,11 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2803,7 +2657,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2839,11 +2693,11 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2888,11 +2742,11 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2929,11 +2783,11 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2959,7 +2813,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2974,7 +2828,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -3027,11 +2881,11 @@ func (ec *executionContext) marshalOCustomer2ᚕᚕᚖgithubᚗcomᚋ99designs } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3067,11 +2921,11 @@ func (ec *executionContext) marshalOCustomer2ᚕᚖgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3171,11 +3025,11 @@ func (ec *executionContext) marshalOItem2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3211,11 +3065,11 @@ func (ec *executionContext) marshalOOrder2ᚕᚖgithubᚗcomᚋ99designsᚋgqlge } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3274,11 +3128,11 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3314,11 +3168,11 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3354,11 +3208,11 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3409,11 +3263,11 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { diff --git a/example/dataloader/server/server.go b/example/dataloader/server/server.go index 25af22c454c..d599330ff90 100644 --- a/example/dataloader/server/server.go +++ b/example/dataloader/server/server.go @@ -5,7 +5,8 @@ import ( "net/http" "github.com/99designs/gqlgen/example/dataloader" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/playground" "github.com/go-chi/chi" ) @@ -13,8 +14,8 @@ func main() { router := chi.NewRouter() router.Use(dataloader.LoaderMiddleware) - router.Handle("/", handler.Playground("Dataloader", "/query")) - router.Handle("/query", handler.GraphQL( + router.Handle("/", playground.Handler("Dataloader", "/query")) + router.Handle("/query", handler.NewDefaultServer( dataloader.NewExecutableSchema(dataloader.Config{Resolvers: &dataloader.Resolver{}}), )) diff --git a/example/fileupload/fileupload_test.go b/example/fileupload/fileupload_test.go index 10fff064b64..9856d639c1e 100644 --- a/example/fileupload/fileupload_test.go +++ b/example/fileupload/fileupload_test.go @@ -14,7 +14,8 @@ import ( "github.com/99designs/gqlgen/example/fileupload/model" "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/stretchr/testify/require" ) @@ -36,7 +37,7 @@ func TestFileUpload(t *testing.T) { Content: string(content), }, nil } - srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolver}))) + srv := httptest.NewServer(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolver}))) defer srv.Close() operations := `{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id, name, content } }", "variables": { "file": null } }` @@ -77,7 +78,7 @@ func TestFileUpload(t *testing.T) { Content: string(content), }, nil } - srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolver}))) + srv := httptest.NewServer(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolver}))) defer srv.Close() operations := `{ "query": "mutation ($req: UploadFile!) { singleUploadWithPayload(req: $req) { id, name, content } }", "variables": { "req": {"file": null, "id": 1 } } }` @@ -121,7 +122,7 @@ func TestFileUpload(t *testing.T) { require.ElementsMatch(t, []string{"test1", "test2"}, contents) return resp, nil } - srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolver}))) + srv := httptest.NewServer(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolver}))) defer srv.Close() operations := `{ "query": "mutation($files: [Upload!]!) { multipleUpload(files: $files) { id, name, content } }", "variables": { "files": [null, null] } }` @@ -174,7 +175,7 @@ func TestFileUpload(t *testing.T) { require.ElementsMatch(t, []string{"test1", "test2"}, contents) return resp, nil } - srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolver}))) + srv := httptest.NewServer(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolver}))) defer srv.Close() operations := `{ "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) { id, name, content } }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } }` @@ -250,8 +251,10 @@ func TestFileUpload(t *testing.T) { } test := func(uploadMaxMemory int64) { - memory := handler.UploadMaxMemory(uploadMaxMemory) - srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolver}), memory)) + hndlr := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) + hndlr.AddTransport(transport.MultipartForm{MaxMemory: uploadMaxMemory}) + + srv := httptest.NewServer(hndlr) defer srv.Close() req := createUploadRequest(t, srv.URL, operations, mapData, files) resp, err := client.Do(req) diff --git a/example/fileupload/generated.go b/example/fileupload/generated.go index 30bdf8d0379..4bf5e6cade3 100644 --- a/example/fileupload/generated.go +++ b/example/fileupload/generated.go @@ -166,46 +166,48 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._Query(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} + return &graphql.Response{ + Data: buf.Bytes(), + } + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._Mutation(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Mutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) + return &graphql.Response{ + Data: buf.Bytes(), + } + } - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - type executionContext struct { - *graphql.RequestContext + *graphql.OperationContext *executableSchema } @@ -367,22 +369,20 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** func (ec *executionContext) _File_id(ctx context.Context, field graphql.CollectedField, obj *model.File) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "File", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -392,34 +392,31 @@ func (ec *executionContext) _File_id(ctx context.Context, field graphql.Collecte return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _File_name(ctx context.Context, field graphql.CollectedField, obj *model.File) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "File", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -429,34 +426,31 @@ func (ec *executionContext) _File_name(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _File_content(ctx context.Context, field graphql.CollectedField, obj *model.File) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "File", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Content, nil @@ -466,41 +460,38 @@ func (ec *executionContext) _File_content(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Mutation_singleUpload(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_singleUpload_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().SingleUpload(rctx, args["file"].(graphql.Upload)) @@ -510,41 +501,38 @@ func (ec *executionContext) _Mutation_singleUpload(ctx context.Context, field gr return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*model.File) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNFile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfileuploadᚋmodelᚐFile(ctx, field.Selections, res) } func (ec *executionContext) _Mutation_singleUploadWithPayload(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_singleUploadWithPayload_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().SingleUploadWithPayload(rctx, args["req"].(model.UploadFile)) @@ -554,41 +542,38 @@ func (ec *executionContext) _Mutation_singleUploadWithPayload(ctx context.Contex return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*model.File) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNFile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfileuploadᚋmodelᚐFile(ctx, field.Selections, res) } func (ec *executionContext) _Mutation_multipleUpload(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_multipleUpload_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().MultipleUpload(rctx, args["files"].([]*graphql.Upload)) @@ -598,41 +583,38 @@ func (ec *executionContext) _Mutation_multipleUpload(ctx context.Context, field return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*model.File) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNFile2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfileuploadᚋmodelᚐFileᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Mutation_multipleUploadWithPayload(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_multipleUploadWithPayload_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().MultipleUploadWithPayload(rctx, args["req"].([]*model.UploadFile)) @@ -642,34 +624,31 @@ func (ec *executionContext) _Mutation_multipleUploadWithPayload(ctx context.Cont return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*model.File) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNFile2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfileuploadᚋmodelᚐFileᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_empty(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Empty(rctx) @@ -679,41 +658,38 @@ func (ec *executionContext) _Query_empty(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) @@ -726,28 +702,25 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() @@ -760,28 +733,25 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -791,34 +761,31 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -831,28 +798,25 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil @@ -862,34 +826,31 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -899,34 +860,31 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -936,34 +894,31 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -976,28 +931,25 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -1007,34 +959,31 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1047,28 +996,25 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1078,34 +1024,31 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1118,28 +1061,25 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -1149,34 +1089,31 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1186,34 +1123,31 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -1223,34 +1157,31 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1263,28 +1194,25 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1294,34 +1222,31 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1334,28 +1259,25 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1365,34 +1287,31 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil @@ -1405,28 +1324,25 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil @@ -1436,34 +1352,31 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil @@ -1473,34 +1386,31 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil @@ -1513,28 +1423,25 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil @@ -1547,28 +1454,25 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil @@ -1578,34 +1482,31 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil @@ -1615,34 +1516,31 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil @@ -1655,28 +1553,25 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -1689,35 +1584,32 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil @@ -1730,28 +1622,25 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil @@ -1764,28 +1653,25 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil @@ -1798,35 +1684,32 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil @@ -1839,28 +1722,25 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil @@ -1873,28 +1753,25 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil @@ -1907,8 +1784,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } @@ -1951,7 +1827,7 @@ func (ec *executionContext) unmarshalInputUploadFile(ctx context.Context, obj in var fileImplementors = []string{"File"} func (ec *executionContext) _File(ctx context.Context, sel ast.SelectionSet, obj *model.File) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, fileImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, fileImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -1988,9 +1864,9 @@ func (ec *executionContext) _File(ctx context.Context, sel ast.SelectionSet, obj var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, mutationImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Mutation", }) @@ -2034,9 +1910,9 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, queryImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) @@ -2078,7 +1954,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2117,7 +1993,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2153,7 +2029,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __FieldImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2199,7 +2075,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __InputValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2235,7 +2111,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __SchemaImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2276,7 +2152,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __TypeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2327,7 +2203,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2347,11 +2223,11 @@ func (ec *executionContext) marshalNFile2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2377,7 +2253,7 @@ func (ec *executionContext) marshalNFile2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalNFile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfileuploadᚋmodelᚐFile(ctx context.Context, sel ast.SelectionSet, v *model.File) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2392,7 +2268,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalInt(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2406,7 +2282,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2420,7 +2296,7 @@ func (ec *executionContext) unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v graphql.Upload) graphql.Marshaler { res := graphql.MarshalUpload(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2466,7 +2342,7 @@ func (ec *executionContext) unmarshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlge func (ec *executionContext) marshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v *graphql.Upload) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2519,11 +2395,11 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2554,7 +2430,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2590,11 +2466,11 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2639,11 +2515,11 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2680,11 +2556,11 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2710,7 +2586,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2725,7 +2601,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2790,11 +2666,11 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2830,11 +2706,11 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2870,11 +2746,11 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2925,11 +2801,11 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { diff --git a/example/fileupload/server/server.go b/example/fileupload/server/server.go index 8ad9c41b237..a1b165de6dd 100644 --- a/example/fileupload/server/server.go +++ b/example/fileupload/server/server.go @@ -7,22 +7,30 @@ import ( "log" "net/http" + "github.com/99designs/gqlgen/graphql/handler/transport" + + "github.com/99designs/gqlgen/graphql/playground" + "github.com/99designs/gqlgen/example/fileupload" "github.com/99designs/gqlgen/example/fileupload/model" "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" ) func main() { - http.Handle("/", handler.Playground("File Upload Demo", "/query")) + http.Handle("/", playground.Handler("File Upload Demo", "/query")) resolver := getResolver() - exec := fileupload.NewExecutableSchema(fileupload.Config{Resolvers: resolver}) var mb int64 = 1 << 20 - uploadMaxMemory := handler.UploadMaxMemory(32 * mb) - uploadMaxSize := handler.UploadMaxSize(50 * mb) - http.Handle("/query", handler.GraphQL(exec, uploadMaxMemory, uploadMaxSize)) + srv := handler.New(fileupload.NewExecutableSchema(fileupload.Config{Resolvers: resolver})) + + srv.AddTransport(transport.MultipartForm{ + MaxMemory: 32 * mb, + MaxUploadSize: 50 * mb, + }) + + http.Handle("/query", srv) log.Print("connect to http://localhost:8087/ for GraphQL playground") log.Fatal(http.ListenAndServe(":8087", nil)) } diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 4502292654e..6ffdee2ed8a 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -189,33 +189,34 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._Query(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} + return &graphql.Response{ + Data: buf.Bytes(), + } + } -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } } type executionContext struct { - *graphql.RequestContext + *graphql.OperationContext *executableSchema } @@ -356,22 +357,20 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** func (ec *executionContext) _Address_id(ctx context.Context, field graphql.CollectedField, obj *model.Address) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Address", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -381,34 +380,31 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(external.ObjectID) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx, field.Selections, res) } func (ec *executionContext) _Address_location(ctx context.Context, field graphql.CollectedField, obj *model.Address) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Address", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Location, nil @@ -421,35 +417,32 @@ func (ec *executionContext) _Address_location(ctx context.Context, field graphql return graphql.Null } res := resTmp.(*model.Point) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, field.Selections, res) } func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_user_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().User(rctx, args["id"].(external.ObjectID)) @@ -462,35 +455,32 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle return graphql.Null } res := resTmp.(*model.User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_search_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Search(rctx, args["input"].(*model.SearchArgs)) @@ -500,41 +490,38 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*model.User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUserᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) @@ -547,28 +534,25 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() @@ -581,28 +565,25 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -612,34 +593,31 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(external.ObjectID) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx, field.Selections, res) } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -649,34 +627,31 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Created, nil @@ -689,28 +664,25 @@ func (ec *executionContext) _User_created(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(time.Time) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOTimestamp2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsBanned, nil @@ -720,34 +692,31 @@ func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(model.Banned) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(ctx, field.Selections, res) } func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.User().PrimitiveResolver(rctx, obj) @@ -757,34 +726,31 @@ func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field g return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_customResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.User().CustomResolver(rctx, obj) @@ -794,34 +760,31 @@ func (ec *executionContext) _User_customResolver(ctx context.Context, field grap return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*model.Point) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, field.Selections, res) } func (ec *executionContext) _User_address(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Address, nil @@ -834,28 +797,25 @@ func (ec *executionContext) _User_address(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(model.Address) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐAddress(ctx, field.Selections, res) } func (ec *executionContext) _User_tier(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Tier, nil @@ -868,28 +828,25 @@ func (ec *executionContext) _User_tier(ctx context.Context, field graphql.Collec return graphql.Null } res := resTmp.(model.Tier) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -899,34 +856,31 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -939,28 +893,25 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil @@ -970,34 +921,31 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -1007,34 +955,31 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1044,34 +989,31 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1084,28 +1026,25 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -1115,34 +1054,31 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1155,28 +1091,25 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1186,34 +1119,31 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1226,28 +1156,25 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -1257,34 +1184,31 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1294,34 +1218,31 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -1331,34 +1252,31 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1371,28 +1289,25 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1402,34 +1317,31 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1442,28 +1354,25 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1473,34 +1382,31 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil @@ -1513,28 +1419,25 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil @@ -1544,34 +1447,31 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil @@ -1581,34 +1481,31 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil @@ -1621,28 +1518,25 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil @@ -1655,28 +1549,25 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil @@ -1686,34 +1577,31 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil @@ -1723,34 +1611,31 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil @@ -1763,28 +1648,25 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -1797,35 +1679,32 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil @@ -1838,28 +1717,25 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil @@ -1872,28 +1748,25 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil @@ -1906,35 +1779,32 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil @@ -1947,28 +1817,25 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil @@ -1981,28 +1848,25 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil @@ -2015,8 +1879,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } @@ -2065,7 +1928,7 @@ func (ec *executionContext) unmarshalInputSearchArgs(ctx context.Context, obj in var addressImplementors = []string{"Address"} func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *model.Address) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, addressImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, addressImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2094,9 +1957,9 @@ func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, queryImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) @@ -2149,7 +2012,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, userImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2220,7 +2083,7 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2259,7 +2122,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2295,7 +2158,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __FieldImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2341,7 +2204,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __InputValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2377,7 +2240,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __SchemaImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2418,7 +2281,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __TypeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2478,7 +2341,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2492,7 +2355,7 @@ func (ec *executionContext) unmarshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexa func (ec *executionContext) marshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx context.Context, sel ast.SelectionSet, v external.ObjectID) graphql.Marshaler { res := model.MarshalID(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2518,7 +2381,7 @@ func (ec *executionContext) unmarshalNPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalNPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2533,7 +2396,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2553,11 +2416,11 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2583,7 +2446,7 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2604,11 +2467,11 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2639,7 +2502,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2675,11 +2538,11 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2724,11 +2587,11 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2765,11 +2628,11 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2795,7 +2658,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2810,7 +2673,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2967,11 +2830,11 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3007,11 +2870,11 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3047,11 +2910,11 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3102,11 +2965,11 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { diff --git a/example/scalars/scalar_test.go b/example/scalars/scalar_test.go index 8268c9acf8d..85ac48c3911 100644 --- a/example/scalars/scalar_test.go +++ b/example/scalars/scalar_test.go @@ -5,8 +5,8 @@ import ( "time" "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/introspection" - "github.com/99designs/gqlgen/handler" "github.com/stretchr/testify/require" ) @@ -21,7 +21,7 @@ type RawUser struct { } func TestScalars(t *testing.T) { - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: &Resolver{}}))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{}}))) t.Run("marshaling", func(t *testing.T) { var resp struct { diff --git a/example/scalars/server/server.go b/example/scalars/server/server.go index 32af870a48f..45cb75c146f 100644 --- a/example/scalars/server/server.go +++ b/example/scalars/server/server.go @@ -5,12 +5,13 @@ import ( "net/http" "github.com/99designs/gqlgen/example/scalars" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/playground" ) func main() { - http.Handle("/", handler.Playground("Starwars", "/query")) - http.Handle("/query", handler.GraphQL(scalars.NewExecutableSchema(scalars.Config{Resolvers: &scalars.Resolver{}}))) + http.Handle("/", playground.Handler("Starwars", "/query")) + http.Handle("/query", handler.NewDefaultServer(scalars.NewExecutableSchema(scalars.Config{Resolvers: &scalars.Resolver{}}))) log.Fatal(http.ListenAndServe(":8084", nil)) } diff --git a/example/selection/generated.go b/example/selection/generated.go index 23dc3fbfbfa..ec6529db471 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -147,33 +147,34 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._Query(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} + return &graphql.Response{ + Data: buf.Bytes(), + } + } -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } } type executionContext struct { - *graphql.RequestContext + *graphql.OperationContext *executableSchema } @@ -274,22 +275,20 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** func (ec *executionContext) _Like_reaction(ctx context.Context, field graphql.CollectedField, obj *Like) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Like", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Reaction, nil @@ -299,34 +298,31 @@ func (ec *executionContext) _Like_reaction(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.CollectedField, obj *Like) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Like", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Sent, nil @@ -336,34 +332,31 @@ func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(time.Time) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.CollectedField, obj *Like) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Like", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Selection, nil @@ -376,28 +369,25 @@ func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.CollectedField, obj *Like) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Like", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Collected, nil @@ -410,28 +400,25 @@ func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Post_message(ctx context.Context, field graphql.CollectedField, obj *Post) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Post", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Message, nil @@ -441,34 +428,31 @@ func (ec *executionContext) _Post_message(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.CollectedField, obj *Post) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Post", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Sent, nil @@ -478,34 +462,31 @@ func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(time.Time) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.CollectedField, obj *Post) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Post", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Selection, nil @@ -518,28 +499,25 @@ func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.CollectedField, obj *Post) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Post", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Collected, nil @@ -552,28 +530,25 @@ func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_events(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Events(rctx) @@ -586,35 +561,32 @@ func (ec *executionContext) _Query_events(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.([]Event) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEventᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) @@ -627,28 +599,25 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() @@ -661,28 +630,25 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -692,34 +658,31 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -732,28 +695,25 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil @@ -763,34 +723,31 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -800,34 +757,31 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -837,34 +791,31 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -877,28 +828,25 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -908,34 +856,31 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -948,28 +893,25 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -979,34 +921,31 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1019,28 +958,25 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -1050,34 +986,31 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1087,34 +1020,31 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -1124,34 +1054,31 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1164,28 +1091,25 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1195,34 +1119,31 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1235,28 +1156,25 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1266,34 +1184,31 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil @@ -1306,28 +1221,25 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil @@ -1337,34 +1249,31 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil @@ -1374,34 +1283,31 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil @@ -1414,28 +1320,25 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil @@ -1448,28 +1351,25 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil @@ -1479,34 +1379,31 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil @@ -1516,34 +1413,31 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil @@ -1556,28 +1450,25 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -1590,35 +1481,32 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil @@ -1631,28 +1519,25 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil @@ -1665,28 +1550,25 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil @@ -1699,35 +1581,32 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil @@ -1740,28 +1619,25 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil @@ -1774,28 +1650,25 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil @@ -1808,8 +1681,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } @@ -1845,7 +1717,7 @@ func (ec *executionContext) _Event(ctx context.Context, sel ast.SelectionSet, ob var likeImplementors = []string{"Like", "Event"} func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj *Like) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, likeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, likeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -1881,7 +1753,7 @@ func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj var postImplementors = []string{"Post", "Event"} func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj *Post) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, postImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, postImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -1917,9 +1789,9 @@ func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, queryImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) @@ -1958,7 +1830,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -1997,7 +1869,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2033,7 +1905,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __FieldImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2079,7 +1951,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __InputValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2115,7 +1987,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __SchemaImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2156,7 +2028,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __TypeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2207,7 +2079,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2216,7 +2088,7 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se func (ec *executionContext) marshalNEvent2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v Event) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2231,7 +2103,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2245,7 +2117,7 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { res := graphql.MarshalTime(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2265,11 +2137,11 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2300,7 +2172,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2336,11 +2208,11 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2385,11 +2257,11 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2426,11 +2298,11 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2456,7 +2328,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2471,7 +2343,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2513,11 +2385,11 @@ func (ec *executionContext) marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2608,11 +2480,11 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2648,11 +2520,11 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2688,11 +2560,11 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2743,11 +2615,11 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { diff --git a/example/selection/selection.go b/example/selection/selection.go index c74f13c9de0..f0b163dd1fc 100644 --- a/example/selection/selection.go +++ b/example/selection/selection.go @@ -22,8 +22,8 @@ type queryResolver struct{ *Resolver } func (r *queryResolver) Events(ctx context.Context) ([]Event, error) { var sels []string - reqCtx := graphql.GetRequestContext(ctx) - fieldSelections := graphql.GetResolverContext(ctx).Field.Selections + reqCtx := graphql.GetOperationContext(ctx) + fieldSelections := graphql.GetFieldContext(ctx).Field.Selections for _, sel := range fieldSelections { switch sel := sel.(type) { case *ast.Field: diff --git a/example/selection/selection_test.go b/example/selection/selection_test.go index 9ccf3a150f4..c6874033220 100644 --- a/example/selection/selection_test.go +++ b/example/selection/selection_test.go @@ -4,12 +4,12 @@ import ( "testing" "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" ) func TestSelection(t *testing.T) { - c := client.New(handler.GraphQL(NewExecutableSchema(Config{Resolvers: &Resolver{}}))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{}}))) query := `{ events { diff --git a/example/selection/server/server.go b/example/selection/server/server.go index 98baf6fce18..4cd1f44c083 100644 --- a/example/selection/server/server.go +++ b/example/selection/server/server.go @@ -5,11 +5,12 @@ import ( "net/http" "github.com/99designs/gqlgen/example/selection" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/playground" ) func main() { - http.Handle("/", handler.Playground("Selection Demo", "/query")) - http.Handle("/query", handler.GraphQL(selection.NewExecutableSchema(selection.Config{Resolvers: &selection.Resolver{}}))) + http.Handle("/", playground.Handler("Selection Demo", "/query")) + http.Handle("/query", handler.NewDefaultServer(selection.NewExecutableSchema(selection.Config{Resolvers: &selection.Resolver{}}))) log.Fatal(http.ListenAndServe(":8086", nil)) } diff --git a/example/starwars/benchmarks_test.go b/example/starwars/benchmarks_test.go index af2401f222b..1aaec2b5794 100644 --- a/example/starwars/benchmarks_test.go +++ b/example/starwars/benchmarks_test.go @@ -6,16 +6,17 @@ import ( "testing" "github.com/99designs/gqlgen/example/starwars/generated" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" ) func BenchmarkSimpleQueryNoArgs(b *testing.B) { - server := handler.GraphQL(generated.NewExecutableSchema(NewResolver())) + server := handler.NewDefaultServer(generated.NewExecutableSchema(NewResolver())) q := `{"query":"{ search(text:\"Luke\") { ... on Human { starships { name } } } }"}` var body strings.Reader r := httptest.NewRequest("POST", "/graphql", &body) + r.Header.Set("Content-Type", "application/json") b.ReportAllocs() b.ResetTimer() @@ -26,7 +27,7 @@ func BenchmarkSimpleQueryNoArgs(b *testing.B) { rec.Body.Reset() server.ServeHTTP(rec, r) if rec.Body.String() != `{"data":{"search":[{"starships":[{"name":"X-Wing"},{"name":"Imperial shuttle"}]}]}}` { - b.Fatalf("Unexpected response") + b.Fatalf("Unexpected response: %s", rec.Body.String()) } } diff --git a/example/starwars/generated/exec.go b/example/starwars/generated/exec.go index b7aac040081..d7aba13380f 100644 --- a/example/starwars/generated/exec.go +++ b/example/starwars/generated/exec.go @@ -490,46 +490,48 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._Query(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} + return &graphql.Response{ + Data: buf.Bytes(), + } + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._Mutation(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Mutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) + return &graphql.Response{ + Data: buf.Bytes(), + } + } - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - type executionContext struct { - *graphql.RequestContext + *graphql.OperationContext *executableSchema } @@ -937,22 +939,20 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Droid", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -962,34 +962,31 @@ func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.Collect return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Droid", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -999,34 +996,31 @@ func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.Colle return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Droid", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Droid().Friends(rctx, obj) @@ -1039,35 +1033,32 @@ func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.([]models.Character) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacterᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Droid", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Droid_friendsConnection_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Droid().FriendsConnection(rctx, obj, args["first"].(*int), args["after"].(*string)) @@ -1077,34 +1068,31 @@ func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*models.FriendsConnection) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsConnection(ctx, field.Selections, res) } func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Droid", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.AppearsIn, nil @@ -1114,34 +1102,31 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]models.Episode) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisodeᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Droid", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PrimaryFunction, nil @@ -1154,28 +1139,25 @@ func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field gr return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "FriendsConnection", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.TotalCount(), nil @@ -1185,34 +1167,31 @@ func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, f return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "FriendsConnection", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.FriendsConnection().Edges(rctx, obj) @@ -1225,28 +1204,25 @@ func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field return graphql.Null } res := resTmp.([]*models.FriendsEdge) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOFriendsEdge2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsEdgeᚄ(ctx, field.Selections, res) } func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "FriendsConnection", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.FriendsConnection().Friends(rctx, obj) @@ -1259,28 +1235,25 @@ func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, fiel return graphql.Null } res := resTmp.([]models.Character) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacterᚄ(ctx, field.Selections, res) } func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "FriendsConnection", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PageInfo(), nil @@ -1290,34 +1263,31 @@ func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, fie return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(models.PageInfo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐPageInfo(ctx, field.Selections, res) } func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *models.FriendsEdge) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "FriendsEdge", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Cursor, nil @@ -1327,34 +1297,31 @@ func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graph return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql.CollectedField, obj *models.FriendsEdge) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "FriendsEdge", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Node, nil @@ -1367,28 +1334,25 @@ func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql return graphql.Null } res := resTmp.(models.Character) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx, field.Selections, res) } func (ec *executionContext) _Human_id(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Human", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -1398,34 +1362,31 @@ func (ec *executionContext) _Human_id(ctx context.Context, field graphql.Collect return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Human_name(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Human", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1435,41 +1396,38 @@ func (ec *executionContext) _Human_name(ctx context.Context, field graphql.Colle return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Human_height(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Human", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Human_height_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Height(args["unit"].(models.LengthUnit)), nil @@ -1479,34 +1437,31 @@ func (ec *executionContext) _Human_height(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Human", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Mass, nil @@ -1519,28 +1474,25 @@ func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.Colle return graphql.Null } res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Human", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Human().Friends(rctx, obj) @@ -1553,35 +1505,32 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.([]models.Character) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacterᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Human", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Human_friendsConnection_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Human().FriendsConnection(rctx, obj, args["first"].(*int), args["after"].(*string)) @@ -1591,34 +1540,31 @@ func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*models.FriendsConnection) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsConnection(ctx, field.Selections, res) } func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Human", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.AppearsIn, nil @@ -1628,34 +1574,31 @@ func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]models.Episode) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisodeᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Human_starships(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Human", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Human().Starships(rctx, obj) @@ -1668,35 +1611,32 @@ func (ec *executionContext) _Human_starships(ctx context.Context, field graphql. return graphql.Null } res := resTmp.([]*models.Starship) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOStarship2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarshipᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Mutation_createReview(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_createReview_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().CreateReview(rctx, args["episode"].(models.Episode), args["review"].(models.Review)) @@ -1709,28 +1649,25 @@ func (ec *executionContext) _Mutation_createReview(ctx context.Context, field gr return graphql.Null } res := resTmp.(*models.Review) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx, field.Selections, res) } func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "PageInfo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.StartCursor, nil @@ -1740,34 +1677,31 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "PageInfo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EndCursor, nil @@ -1777,34 +1711,31 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "PageInfo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.HasNextPage, nil @@ -1814,41 +1745,38 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_hero_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Hero(rctx, args["episode"].(*models.Episode)) @@ -1861,35 +1789,32 @@ func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.Colle return graphql.Null } res := resTmp.(models.Character) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx, field.Selections, res) } func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_reviews_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Reviews(rctx, args["episode"].(models.Episode), args["since"].(*time.Time)) @@ -1899,41 +1824,38 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*models.Review) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReviewᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_search_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Search(rctx, args["text"].(string)) @@ -1943,41 +1865,38 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]models.SearchResult) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐSearchResultᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_character(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_character_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Character(rctx, args["id"].(string)) @@ -1990,35 +1909,32 @@ func (ec *executionContext) _Query_character(ctx context.Context, field graphql. return graphql.Null } res := resTmp.(models.Character) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx, field.Selections, res) } func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_droid_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Droid(rctx, args["id"].(string)) @@ -2031,35 +1947,32 @@ func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*models.Droid) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalODroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐDroid(ctx, field.Selections, res) } func (ec *executionContext) _Query_human(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_human_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Human(rctx, args["id"].(string)) @@ -2072,35 +1985,32 @@ func (ec *executionContext) _Query_human(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*models.Human) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐHuman(ctx, field.Selections, res) } func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_starship_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Starship(rctx, args["id"].(string)) @@ -2113,35 +2023,32 @@ func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*models.Starship) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarship(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) @@ -2154,28 +2061,25 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() @@ -2188,28 +2092,25 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.CollectedField, obj *models.Review) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Review", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Stars, nil @@ -2219,34 +2120,31 @@ func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Review_commentary(ctx context.Context, field graphql.CollectedField, obj *models.Review) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Review", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Commentary, nil @@ -2259,28 +2157,25 @@ func (ec *executionContext) _Review_commentary(ctx context.Context, field graphq return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Review_time(ctx context.Context, field graphql.CollectedField, obj *models.Review) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Review", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Time, nil @@ -2293,28 +2188,25 @@ func (ec *executionContext) _Review_time(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(time.Time) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.CollectedField, obj *models.Starship) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Starship", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -2324,34 +2216,31 @@ func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.CollectedField, obj *models.Starship) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Starship", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -2361,41 +2250,38 @@ func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Starship_length(ctx context.Context, field graphql.CollectedField, obj *models.Starship) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Starship", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Starship_length_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Starship().Length(rctx, obj, args["unit"].(*models.LengthUnit)) @@ -2405,34 +2291,31 @@ func (ec *executionContext) _Starship_length(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Starship_history(ctx context.Context, field graphql.CollectedField, obj *models.Starship) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Starship", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.History, nil @@ -2442,34 +2325,31 @@ func (ec *executionContext) _Starship_history(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([][]int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNInt2ᚕᚕintᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -2479,34 +2359,31 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -2519,28 +2396,25 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil @@ -2550,34 +2424,31 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -2587,34 +2458,31 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -2624,34 +2492,31 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -2664,28 +2529,25 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -2695,34 +2557,31 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -2735,28 +2594,25 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -2766,34 +2622,31 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -2806,28 +2659,25 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -2837,34 +2687,31 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -2874,34 +2721,31 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -2911,34 +2755,31 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -2951,28 +2792,25 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -2982,34 +2820,31 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -3022,28 +2857,25 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -3053,34 +2885,31 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil @@ -3093,28 +2922,25 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil @@ -3124,34 +2950,31 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil @@ -3161,34 +2984,31 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil @@ -3201,28 +3021,25 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil @@ -3235,28 +3052,25 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil @@ -3266,34 +3080,31 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil @@ -3303,34 +3114,31 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil @@ -3343,28 +3151,25 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -3377,35 +3182,32 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil @@ -3418,28 +3220,25 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil @@ -3452,28 +3251,25 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil @@ -3486,35 +3282,32 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil @@ -3527,28 +3320,25 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil @@ -3561,28 +3351,25 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil @@ -3595,8 +3382,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } @@ -3683,7 +3469,7 @@ func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.Selection var droidImplementors = []string{"Droid", "Character", "SearchResult"} func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, obj *models.Droid) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, droidImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, droidImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -3747,7 +3533,7 @@ func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, ob var friendsConnectionImplementors = []string{"FriendsConnection"} func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.SelectionSet, obj *models.FriendsConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, friendsConnectionImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, friendsConnectionImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -3801,7 +3587,7 @@ func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.Sele var friendsEdgeImplementors = []string{"FriendsEdge"} func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionSet, obj *models.FriendsEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, friendsEdgeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, friendsEdgeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -3830,7 +3616,7 @@ func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionS var humanImplementors = []string{"Human", "Character", "SearchResult"} func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, obj *models.Human) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, humanImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, humanImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -3910,9 +3696,9 @@ func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, ob var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, mutationImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Mutation", }) @@ -3938,7 +3724,7 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) var pageInfoImplementors = []string{"PageInfo"} func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *models.PageInfo) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, pageInfoImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -3975,9 +3761,9 @@ func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, queryImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) @@ -4088,7 +3874,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var reviewImplementors = []string{"Review"} func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, obj *models.Review) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, reviewImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, reviewImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -4119,7 +3905,7 @@ func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, o var starshipImplementors = []string{"Starship", "SearchResult"} func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, obj *models.Starship) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, starshipImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, starshipImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -4170,7 +3956,7 @@ func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -4209,7 +3995,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -4245,7 +4031,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __FieldImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -4291,7 +4077,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __InputValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -4327,7 +4113,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __SchemaImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -4368,7 +4154,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __TypeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -4419,7 +4205,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -4428,7 +4214,7 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se func (ec *executionContext) marshalNCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v models.Character) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -4474,11 +4260,11 @@ func (ec *executionContext) marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -4509,7 +4295,7 @@ func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v inter func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { res := graphql.MarshalFloat(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -4522,7 +4308,7 @@ func (ec *executionContext) marshalNFriendsConnection2githubᚗcomᚋ99designs func (ec *executionContext) marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v *models.FriendsConnection) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -4536,7 +4322,7 @@ func (ec *executionContext) marshalNFriendsEdge2githubᚗcomᚋ99designsᚋgqlge func (ec *executionContext) marshalNFriendsEdge2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v *models.FriendsEdge) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -4551,7 +4337,7 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalID(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -4565,7 +4351,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalInt(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -4647,11 +4433,11 @@ func (ec *executionContext) marshalNReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -4677,7 +4463,7 @@ func (ec *executionContext) marshalNReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlg func (ec *executionContext) marshalNReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx context.Context, sel ast.SelectionSet, v *models.Review) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -4691,7 +4477,7 @@ func (ec *executionContext) unmarshalNReviewInput2githubᚗcomᚋ99designsᚋgql func (ec *executionContext) marshalNSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v models.SearchResult) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -4708,11 +4494,11 @@ func (ec *executionContext) marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -4742,7 +4528,7 @@ func (ec *executionContext) marshalNStarship2githubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalNStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarship(ctx context.Context, sel ast.SelectionSet, v *models.Starship) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -4757,7 +4543,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -4777,11 +4563,11 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -4812,7 +4598,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -4848,11 +4634,11 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -4897,11 +4683,11 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -4938,11 +4724,11 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -4968,7 +4754,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -4983,7 +4769,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -5032,11 +4818,11 @@ func (ec *executionContext) marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -5115,11 +4901,11 @@ func (ec *executionContext) marshalOFriendsEdge2ᚕᚖgithubᚗcomᚋ99designs } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -5251,11 +5037,11 @@ func (ec *executionContext) marshalOStarship2ᚕᚖgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -5344,11 +5130,11 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -5384,11 +5170,11 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -5424,11 +5210,11 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -5479,11 +5265,11 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { diff --git a/example/starwars/server/server.go b/example/starwars/server/server.go index d082d3d92e9..cd1af69ad76 100644 --- a/example/starwars/server/server.go +++ b/example/starwars/server/server.go @@ -9,20 +9,22 @@ import ( "github.com/99designs/gqlgen/example/starwars" "github.com/99designs/gqlgen/example/starwars/generated" "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/playground" ) func main() { - http.Handle("/", handler.Playground("Starwars", "/query")) - http.Handle("/query", handler.GraphQL(generated.NewExecutableSchema(starwars.NewResolver()), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - rc := graphql.GetResolverContext(ctx) - fmt.Println("Entered", rc.Object, rc.Field.Name) - res, err = next(ctx) - fmt.Println("Left", rc.Object, rc.Field.Name, "=>", res, err) - return res, err - }), - )) + srv := handler.NewDefaultServer(generated.NewExecutableSchema(starwars.NewResolver())) + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + rc := graphql.GetFieldContext(ctx) + fmt.Println("Entered", rc.Object, rc.Field.Name) + res, err = next(ctx) + fmt.Println("Left", rc.Object, rc.Field.Name, "=>", res, err) + return res, err + }) + + http.Handle("/", playground.Handler("Starwars", "/query")) + http.Handle("/query", srv) log.Fatal(http.ListenAndServe(":8080", nil)) } diff --git a/example/starwars/starwars_test.go b/example/starwars/starwars_test.go index 9e9f8172f5d..c720270e2b9 100644 --- a/example/starwars/starwars_test.go +++ b/example/starwars/starwars_test.go @@ -5,13 +5,13 @@ import ( "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/example/starwars/generated" + "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/introspection" - "github.com/99designs/gqlgen/handler" "github.com/stretchr/testify/require" ) func TestStarwars(t *testing.T) { - c := client.New(handler.GraphQL(generated.NewExecutableSchema(NewResolver()))) + c := client.New(handler.NewDefaultServer(generated.NewExecutableSchema(NewResolver()))) t.Run("Lukes starships", func(t *testing.T) { var resp struct { diff --git a/example/todo/generated.go b/example/todo/generated.go index 805aa1818c8..ddf1f6e4263 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -164,50 +164,52 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._queryMiddleware(ctx, op, func(ctx context.Context) (interface{}, error) { - return ec._MyQuery(ctx, op.SelectionSet), nil - }) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._queryMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error) { + return ec._MyQuery(ctx, rc.Operation.SelectionSet), nil + }) + var buf bytes.Buffer + data.MarshalGQL(&buf) -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} + return &graphql.Response{ + Data: buf.Bytes(), + } + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._mutationMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error) { + return ec._MyMutation(ctx, rc.Operation.SelectionSet), nil + }) + var buf bytes.Buffer + data.MarshalGQL(&buf) - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._mutationMiddleware(ctx, op, func(ctx context.Context) (interface{}, error) { - return ec._MyMutation(ctx, op.SelectionSet), nil - }) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) + return &graphql.Response{ + Data: buf.Bytes(), + } + } - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - type executionContext struct { - *graphql.RequestContext + *graphql.OperationContext *executableSchema } @@ -464,8 +466,8 @@ func (ec *executionContext) _mutationMiddleware(ctx context.Context, obj *ast.Op } func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) interface{} { - rctx := graphql.GetResolverContext(ctx) - for _, d := range rctx.Field.Directives { + fc := graphql.GetFieldContext(ctx) + for _, d := range fc.Field.Directives { switch d.Name { case "user": rawArgs := d.ArgumentMap(ec.Variables) @@ -496,70 +498,65 @@ func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj interface{ // region **************************** field.gotpl ***************************** func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MyMutation", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.MyMutation().CreateTodo(rctx, args["todo"].(TodoInput)) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MyMutation", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_MyMutation_updateTodo_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.MyMutation().UpdateTodo(rctx, args["id"].(int), args["changes"].(map[string]interface{})) @@ -569,35 +566,32 @@ func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field gr return graphql.Null } res := resTmp.(*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MyQuery", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.MyQuery().Todo(rctx, args["id"].(int)) @@ -607,28 +601,25 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MyQuery", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.MyQuery().LastTodo(rctx) @@ -638,69 +629,63 @@ func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql return graphql.Null } res := resTmp.(*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MyQuery", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.MyQuery().Todos(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MyQuery", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_MyQuery___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) @@ -710,28 +695,25 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MyQuery", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() @@ -741,96 +723,87 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql return graphql.Null } res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Todo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2int(ctx, field.Selections, res) } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Todo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Text, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Todo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -861,68 +834,62 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -932,130 +899,118 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1065,62 +1020,56 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1130,62 +1079,56 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1195,130 +1138,118 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1328,62 +1259,56 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1393,62 +1318,56 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil @@ -1458,96 +1377,87 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil @@ -1557,28 +1467,25 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil @@ -1588,96 +1495,87 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil @@ -1687,28 +1585,25 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -1718,35 +1613,32 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil @@ -1756,28 +1648,25 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil @@ -1787,28 +1676,25 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil @@ -1818,35 +1704,32 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil @@ -1856,28 +1739,25 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil @@ -1887,28 +1767,25 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil @@ -1918,8 +1795,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } @@ -1962,9 +1838,9 @@ func (ec *executionContext) unmarshalInputTodoInput(ctx context.Context, obj int var myMutationImplementors = []string{"MyMutation"} func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, myMutationImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, myMutationImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "MyMutation", }) @@ -1995,9 +1871,9 @@ func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSe var myQueryImplementors = []string{"MyQuery"} func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, myQueryImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, myQueryImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "MyQuery", }) @@ -2061,7 +1937,7 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) var todoImplementors = []string{"Todo"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, todoImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2098,7 +1974,7 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2137,7 +2013,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2173,7 +2049,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __FieldImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2219,7 +2095,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __InputValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2255,7 +2131,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __SchemaImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2296,7 +2172,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __TypeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2347,7 +2223,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2361,7 +2237,7 @@ func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalIntID(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2377,14 +2253,14 @@ func (ec *executionContext) unmarshalNMap2map(ctx context.Context, v interface{} func (ec *executionContext) marshalNMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := graphql.MarshalMap(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2407,7 +2283,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2427,11 +2303,11 @@ func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2457,7 +2333,7 @@ func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2482,11 +2358,11 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2517,7 +2393,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2553,11 +2429,11 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2602,11 +2478,11 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2643,11 +2519,11 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2673,7 +2549,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2688,7 +2564,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2764,11 +2640,11 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2804,11 +2680,11 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2844,11 +2720,11 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2899,11 +2775,11 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { diff --git a/example/todo/server/server.go b/example/todo/server/server.go index 6e594d79ab1..4c105427cfa 100644 --- a/example/todo/server/server.go +++ b/example/todo/server/server.go @@ -8,19 +8,20 @@ import ( "runtime/debug" "github.com/99designs/gqlgen/example/todo" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/playground" ) func main() { - http.Handle("/", handler.Playground("Todo", "/query")) - http.Handle("/query", handler.GraphQL( - todo.NewExecutableSchema(todo.New()), - handler.RecoverFunc(func(ctx context.Context, err interface{}) error { - // send this panic somewhere - log.Print(err) - debug.PrintStack() - return errors.New("user message on panic") - }), - )) + srv := handler.NewDefaultServer(todo.NewExecutableSchema(todo.New())) + srv.SetRecoverFunc(func(ctx context.Context, err interface{}) (userMessage error) { + // send this panic somewhere + log.Print(err) + debug.PrintStack() + return errors.New("user message on panic") + }) + + http.Handle("/", playground.Handler("Todo", "/query")) + http.Handle("/query", srv) log.Fatal(http.ListenAndServe(":8081", nil)) } diff --git a/example/todo/todo_test.go b/example/todo/todo_test.go index 965f62b7606..7423580f8c8 100644 --- a/example/todo/todo_test.go +++ b/example/todo/todo_test.go @@ -4,13 +4,13 @@ import ( "testing" "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/introspection" - "github.com/99designs/gqlgen/handler" "github.com/stretchr/testify/require" ) func TestTodo(t *testing.T) { - c := client.New(handler.GraphQL(NewExecutableSchema(New()))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(New()))) var resp struct { CreateTodo struct{ ID string } @@ -180,7 +180,7 @@ func TestTodo(t *testing.T) { } func TestSkipAndIncludeDirectives(t *testing.T) { - c := client.New(handler.GraphQL(NewExecutableSchema(New()))) + c := client.New(handler.NewDefaultServer(NewExecutableSchema(New()))) t.Run("skip on field", func(t *testing.T) { var resp map[string]interface{} diff --git a/example/type-system-extension/directive.go b/example/type-system-extension/directive.go index 8b49e929ecd..2b3ff918cec 100644 --- a/example/type-system-extension/directive.go +++ b/example/type-system-extension/directive.go @@ -8,37 +8,37 @@ import ( ) func EnumLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { - rc := graphql.GetResolverContext(ctx) + rc := graphql.GetFieldContext(ctx) log.Printf("enum logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) return next(ctx) } func FieldLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { - rc := graphql.GetResolverContext(ctx) + rc := graphql.GetFieldContext(ctx) log.Printf("field logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) return next(ctx) } func InputLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { - rc := graphql.GetResolverContext(ctx) + rc := graphql.GetFieldContext(ctx) log.Printf("input object logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) return next(ctx) } func ObjectLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { - rc := graphql.GetResolverContext(ctx) + rc := graphql.GetFieldContext(ctx) log.Printf("object logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) return next(ctx) } func ScalarLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { - rc := graphql.GetResolverContext(ctx) + rc := graphql.GetFieldContext(ctx) log.Printf("scalar logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) return next(ctx) } func UnionLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { - rc := graphql.GetResolverContext(ctx) + rc := graphql.GetFieldContext(ctx) log.Printf("union logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) return next(ctx) } diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 117ca100f71..ba450dd23b9 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -159,46 +159,48 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._MyQuery(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._MyQuery(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} + return &graphql.Response{ + Data: buf.Bytes(), + } + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._MyMutation(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._MyMutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) + return &graphql.Response{ + Data: buf.Bytes(), + } + } - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - type executionContext struct { - *graphql.RequestContext + *graphql.OperationContext *executableSchema } @@ -377,29 +379,27 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MyMutation", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.MyMutation().CreateTodo(rctx, args["todo"].(TodoInput)) @@ -409,34 +409,31 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MyQuery", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.MyQuery().Todos(rctx) @@ -446,41 +443,38 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MyQuery", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.MyQuery().Todo(rctx, args["id"].(string)) @@ -493,35 +487,32 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MyQuery", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_MyQuery___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) @@ -534,28 +525,25 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "MyQuery", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() @@ -568,28 +556,25 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql return graphql.Null } res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Todo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil @@ -599,34 +584,31 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Todo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Text, nil @@ -636,34 +618,31 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Todo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.State, nil @@ -673,34 +652,31 @@ func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.Colle return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(State) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(ctx, field.Selections, res) } func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Todo", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -730,34 +706,31 @@ func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -767,34 +740,31 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -807,28 +777,25 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil @@ -838,34 +805,31 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -875,34 +839,31 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -912,34 +873,31 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -952,28 +910,25 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -983,34 +938,31 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1023,28 +975,25 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1054,34 +1003,31 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1094,28 +1040,25 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -1125,34 +1068,31 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1162,34 +1102,31 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -1199,34 +1136,31 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1239,28 +1173,25 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1270,34 +1201,31 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1310,28 +1238,25 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1341,34 +1266,31 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil @@ -1381,28 +1303,25 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil @@ -1412,34 +1331,31 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil @@ -1449,34 +1365,31 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil @@ -1489,28 +1402,25 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil @@ -1523,28 +1433,25 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil @@ -1554,34 +1461,31 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil @@ -1591,34 +1495,31 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil @@ -1631,28 +1532,25 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -1665,35 +1563,32 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil @@ -1706,28 +1601,25 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil @@ -1740,28 +1632,25 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil @@ -1774,35 +1663,32 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil @@ -1815,28 +1701,25 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil @@ -1849,28 +1732,25 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil @@ -1883,8 +1763,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } @@ -1947,9 +1826,9 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj var myMutationImplementors = []string{"MyMutation"} func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, myMutationImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, myMutationImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "MyMutation", }) @@ -1978,9 +1857,9 @@ func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSe var myQueryImplementors = []string{"MyQuery"} func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, myQueryImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, myQueryImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "MyQuery", }) @@ -2033,7 +1912,7 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) var todoImplementors = []string{"Todo", "Node", "Data"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, todoImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2075,7 +1954,7 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2114,7 +1993,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2150,7 +2029,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __FieldImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2196,7 +2075,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __InputValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2232,7 +2111,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __SchemaImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2273,7 +2152,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __TypeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2324,7 +2203,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2338,7 +2217,7 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalID(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2361,7 +2240,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2381,11 +2260,11 @@ func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2411,7 +2290,7 @@ func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2436,11 +2315,11 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2471,7 +2350,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2507,11 +2386,11 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2556,11 +2435,11 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2597,11 +2476,11 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2627,7 +2506,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2642,7 +2521,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2718,11 +2597,11 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2758,11 +2637,11 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2798,11 +2677,11 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2853,11 +2732,11 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { diff --git a/example/type-system-extension/server/server.go b/example/type-system-extension/server/server.go index d214efdfeb9..e7f703b4155 100644 --- a/example/type-system-extension/server/server.go +++ b/example/type-system-extension/server/server.go @@ -5,8 +5,10 @@ import ( "net/http" "os" + "github.com/99designs/gqlgen/graphql/playground" + extension "github.com/99designs/gqlgen/example/type-system-extension" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" ) const defaultPort = "8080" @@ -17,8 +19,8 @@ func main() { port = defaultPort } - http.Handle("/", handler.Playground("GraphQL playground", "/query")) - http.Handle("/query", handler.GraphQL( + http.Handle("/", playground.Handler("GraphQL playground", "/query")) + http.Handle("/query", handler.NewDefaultServer( extension.NewExecutableSchema( extension.Config{ Resolvers: extension.NewRootResolver(), diff --git a/go.mod b/go.mod index ade251b80d6..a5a71ee23bd 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/gorilla/websocket v1.2.0 github.com/hashicorp/golang-lru v0.5.0 github.com/kr/pretty v0.1.0 // indirect + github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd // indirect github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 github.com/opentracing/basictracer-go v1.0.0 // indirect github.com/opentracing/opentracing-go v1.0.2 diff --git a/go.sum b/go.sum index 5f5906b0e90..cb41d3f4217 100644 --- a/go.sum +++ b/go.sum @@ -23,6 +23,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd h1:HvFwW+cm9bCbZ/+vuGNq7CRWXql8c0y8nGeYpqmpvmk= +github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 h1:zCoDWFD5nrJJVjbXiDZcVhOBSzKn3o9LgRLLMRNuru8= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/opentracing/basictracer-go v1.0.0 h1:YyUAhaEfjoWXclZVJ9sGoNct7j4TVk7lZWlQw5UXuoo= diff --git a/graphql/cache.go b/graphql/cache.go new file mode 100644 index 00000000000..24294f72d7f --- /dev/null +++ b/graphql/cache.go @@ -0,0 +1,27 @@ +package graphql + +// Cache is a shared store for APQ and query AST caching +type Cache interface { + // Get looks up a key's value from the cache. + Get(key string) (value interface{}, ok bool) + + // Add adds a value to the cache. + Add(key string, value interface{}) +} + +// MapCache is the simplest implementation of a cache, because it can not evict it should only be used in tests +type MapCache map[string]interface{} + +// Get looks up a key's value from the cache. +func (m MapCache) Get(key string) (value interface{}, ok bool) { + v, ok := m[key] + return v, ok +} + +// Add adds a value to the cache. +func (m MapCache) Add(key string, value interface{}) { m[key] = value } + +type NoCache struct{} + +func (n NoCache) Get(key string) (value interface{}, ok bool) { return nil, false } +func (n NoCache) Add(key string, value interface{}) {} diff --git a/graphql/context.go b/graphql/context.go deleted file mode 100644 index eb98251d79b..00000000000 --- a/graphql/context.go +++ /dev/null @@ -1,312 +0,0 @@ -package graphql - -import ( - "context" - "errors" - "fmt" - "sync" - - "github.com/vektah/gqlparser/ast" - "github.com/vektah/gqlparser/gqlerror" -) - -type Resolver func(ctx context.Context) (res interface{}, err error) -type FieldMiddleware func(ctx context.Context, next Resolver) (res interface{}, err error) -type RequestMiddleware func(ctx context.Context, next func(ctx context.Context) []byte) []byte -type ComplexityLimitFunc func(ctx context.Context) int - -type RequestContext struct { - RawQuery string - Variables map[string]interface{} - OperationName string - Doc *ast.QueryDocument - - ComplexityLimit int - OperationComplexity int - DisableIntrospection bool - - // ErrorPresenter will be used to generate the error - // message from errors given to Error(). - ErrorPresenter ErrorPresenterFunc - Recover RecoverFunc - ResolverMiddleware FieldMiddleware - DirectiveMiddleware FieldMiddleware - RequestMiddleware RequestMiddleware - Tracer Tracer - - errorsMu sync.Mutex - Errors gqlerror.List - extensionsMu sync.Mutex - Extensions map[string]interface{} -} - -func (rc *RequestContext) Validate(ctx context.Context) error { - if rc.Doc == nil { - return errors.New("field 'Doc' must be required") - } - if rc.RawQuery == "" { - return errors.New("field 'RawQuery' must be required") - } - if rc.Variables == nil { - rc.Variables = make(map[string]interface{}) - } - if rc.ResolverMiddleware == nil { - rc.ResolverMiddleware = DefaultResolverMiddleware - } - if rc.DirectiveMiddleware == nil { - rc.DirectiveMiddleware = DefaultDirectiveMiddleware - } - if rc.RequestMiddleware == nil { - rc.RequestMiddleware = DefaultRequestMiddleware - } - if rc.Recover == nil { - rc.Recover = DefaultRecover - } - if rc.ErrorPresenter == nil { - rc.ErrorPresenter = DefaultErrorPresenter - } - if rc.Tracer == nil { - rc.Tracer = &NopTracer{} - } - if rc.ComplexityLimit < 0 { - return errors.New("field 'ComplexityLimit' value must be 0 or more") - } - - return nil -} - -func DefaultResolverMiddleware(ctx context.Context, next Resolver) (res interface{}, err error) { - return next(ctx) -} - -func DefaultDirectiveMiddleware(ctx context.Context, next Resolver) (res interface{}, err error) { - return next(ctx) -} - -func DefaultRequestMiddleware(ctx context.Context, next func(ctx context.Context) []byte) []byte { - return next(ctx) -} - -// Deprecated: construct RequestContext directly & call Validate method. -func NewRequestContext(doc *ast.QueryDocument, query string, variables map[string]interface{}) *RequestContext { - rc := &RequestContext{ - Doc: doc, - RawQuery: query, - Variables: variables, - } - err := rc.Validate(context.Background()) - if err != nil { - panic(err) - } - - return rc -} - -type key string - -const ( - request key = "request_context" - resolver key = "resolver_context" -) - -func GetRequestContext(ctx context.Context) *RequestContext { - if val, ok := ctx.Value(request).(*RequestContext); ok { - return val - } - return nil -} - -func WithRequestContext(ctx context.Context, rc *RequestContext) context.Context { - return context.WithValue(ctx, request, rc) -} - -type ResolverContext struct { - Parent *ResolverContext - // The name of the type this field belongs to - Object string - // These are the args after processing, they can be mutated in middleware to change what the resolver will get. - Args map[string]interface{} - // The raw field - Field CollectedField - // The index of array in path. - Index *int - // The result object of resolver - Result interface{} - // IsMethod indicates if the resolver is a method - IsMethod bool -} - -func (r *ResolverContext) Path() []interface{} { - var path []interface{} - for it := r; it != nil; it = it.Parent { - if it.Index != nil { - path = append(path, *it.Index) - } else if it.Field.Field != nil { - path = append(path, it.Field.Alias) - } - } - - // because we are walking up the chain, all the elements are backwards, do an inplace flip. - for i := len(path)/2 - 1; i >= 0; i-- { - opp := len(path) - 1 - i - path[i], path[opp] = path[opp], path[i] - } - - return path -} - -func GetResolverContext(ctx context.Context) *ResolverContext { - if val, ok := ctx.Value(resolver).(*ResolverContext); ok { - return val - } - return nil -} - -func WithResolverContext(ctx context.Context, rc *ResolverContext) context.Context { - rc.Parent = GetResolverContext(ctx) - return context.WithValue(ctx, resolver, rc) -} - -// This is just a convenient wrapper method for CollectFields -func CollectFieldsCtx(ctx context.Context, satisfies []string) []CollectedField { - resctx := GetResolverContext(ctx) - return CollectFields(GetRequestContext(ctx), resctx.Field.Selections, satisfies) -} - -// CollectAllFields returns a slice of all GraphQL field names that were selected for the current resolver context. -// The slice will contain the unique set of all field names requested regardless of fragment type conditions. -func CollectAllFields(ctx context.Context) []string { - resctx := GetResolverContext(ctx) - collected := CollectFields(GetRequestContext(ctx), resctx.Field.Selections, nil) - uniq := make([]string, 0, len(collected)) -Next: - for _, f := range collected { - for _, name := range uniq { - if name == f.Name { - continue Next - } - } - uniq = append(uniq, f.Name) - } - return uniq -} - -// Errorf sends an error string to the client, passing it through the formatter. -func (c *RequestContext) Errorf(ctx context.Context, format string, args ...interface{}) { - c.errorsMu.Lock() - defer c.errorsMu.Unlock() - - c.Errors = append(c.Errors, c.ErrorPresenter(ctx, fmt.Errorf(format, args...))) -} - -// Error sends an error to the client, passing it through the formatter. -func (c *RequestContext) Error(ctx context.Context, err error) { - c.errorsMu.Lock() - defer c.errorsMu.Unlock() - - c.Errors = append(c.Errors, c.ErrorPresenter(ctx, err)) -} - -// HasError returns true if the current field has already errored -func (c *RequestContext) HasError(rctx *ResolverContext) bool { - c.errorsMu.Lock() - defer c.errorsMu.Unlock() - path := rctx.Path() - - for _, err := range c.Errors { - if equalPath(err.Path, path) { - return true - } - } - return false -} - -// GetErrors returns a list of errors that occurred in the current field -func (c *RequestContext) GetErrors(rctx *ResolverContext) gqlerror.List { - c.errorsMu.Lock() - defer c.errorsMu.Unlock() - path := rctx.Path() - - var errs gqlerror.List - for _, err := range c.Errors { - if equalPath(err.Path, path) { - errs = append(errs, err) - } - } - return errs -} - -func equalPath(a []interface{}, b []interface{}) bool { - if len(a) != len(b) { - return false - } - - for i := 0; i < len(a); i++ { - if a[i] != b[i] { - return false - } - } - - return true -} - -// AddError is a convenience method for adding an error to the current response -func AddError(ctx context.Context, err error) { - GetRequestContext(ctx).Error(ctx, err) -} - -// AddErrorf is a convenience method for adding an error to the current response -func AddErrorf(ctx context.Context, format string, args ...interface{}) { - GetRequestContext(ctx).Errorf(ctx, format, args...) -} - -// RegisterExtension registers an extension, returns error if extension has already been registered -func (c *RequestContext) RegisterExtension(key string, value interface{}) error { - c.extensionsMu.Lock() - defer c.extensionsMu.Unlock() - - if c.Extensions == nil { - c.Extensions = make(map[string]interface{}) - } - - if _, ok := c.Extensions[key]; ok { - return fmt.Errorf("extension already registered for key %s", key) - } - - c.Extensions[key] = value - return nil -} - -// ChainFieldMiddleware add chain by FieldMiddleware -func ChainFieldMiddleware(handleFunc ...FieldMiddleware) FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next Resolver) (interface{}, error) { - var ( - chainHandler Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } - } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next Resolver) (interface{}, error) { - return next(ctx) - } -} diff --git a/graphql/context_field.go b/graphql/context_field.go new file mode 100644 index 00000000000..802b60e4c5e --- /dev/null +++ b/graphql/context_field.go @@ -0,0 +1,90 @@ +package graphql + +import ( + "context" + "time" +) + +type key string + +const resolverCtx key = "resolver_context" + +// Deprecated: Use FieldContext instead +type ResolverContext = FieldContext + +type FieldContext struct { + Parent *FieldContext + // The name of the type this field belongs to + Object string + // These are the args after processing, they can be mutated in middleware to change what the resolver will get. + Args map[string]interface{} + // The raw field + Field CollectedField + // The index of array in path. + Index *int + // The result object of resolver + Result interface{} + // IsMethod indicates if the resolver is a method + IsMethod bool +} + +type FieldStats struct { + // When field execution started + Started time.Time + + // When argument marshaling finished + ArgumentsCompleted time.Time + + // When the field completed running all middleware. Not available inside field middleware! + Completed time.Time +} + +func (r *FieldContext) Path() []interface{} { + var path []interface{} + for it := r; it != nil; it = it.Parent { + if it.Index != nil { + path = append(path, *it.Index) + } else if it.Field.Field != nil { + path = append(path, it.Field.Alias) + } + } + + // because we are walking up the chain, all the elements are backwards, do an inplace flip. + for i := len(path)/2 - 1; i >= 0; i-- { + opp := len(path) - 1 - i + path[i], path[opp] = path[opp], path[i] + } + + return path +} + +// Deprecated: Use GetFieldContext instead +func GetResolverContext(ctx context.Context) *ResolverContext { + return GetFieldContext(ctx) +} + +func GetFieldContext(ctx context.Context) *FieldContext { + if val, ok := ctx.Value(resolverCtx).(*FieldContext); ok { + return val + } + return nil +} + +func WithFieldContext(ctx context.Context, rc *FieldContext) context.Context { + rc.Parent = GetFieldContext(ctx) + return context.WithValue(ctx, resolverCtx, rc) +} + +func equalPath(a []interface{}, b []interface{}) bool { + if len(a) != len(b) { + return false + } + + for i := 0; i < len(a); i++ { + if a[i] != b[i] { + return false + } + } + + return true +} diff --git a/graphql/context_field_test.go b/graphql/context_field_test.go new file mode 100644 index 00000000000..05e6cd1a741 --- /dev/null +++ b/graphql/context_field_test.go @@ -0,0 +1,33 @@ +package graphql + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/ast" +) + +func TestGetResolverContext(t *testing.T) { + require.Nil(t, GetFieldContext(context.Background())) + + rc := &FieldContext{} + require.Equal(t, rc, GetFieldContext(WithFieldContext(context.Background(), rc))) +} + +func testContext(sel ast.SelectionSet) context.Context { + + ctx := context.Background() + + rqCtx := &OperationContext{} + ctx = WithOperationContext(ctx, rqCtx) + + root := &FieldContext{ + Field: CollectedField{ + Selections: sel, + }, + } + ctx = WithFieldContext(ctx, root) + + return ctx +} diff --git a/graphql/context_operation.go b/graphql/context_operation.go new file mode 100644 index 00000000000..cf1a279ec7b --- /dev/null +++ b/graphql/context_operation.go @@ -0,0 +1,99 @@ +package graphql + +import ( + "context" + "errors" + + "github.com/vektah/gqlparser/ast" +) + +// Deprecated: Please update all references to OperationContext instead +type RequestContext = OperationContext + +type OperationContext struct { + RawQuery string + Variables map[string]interface{} + OperationName string + Doc *ast.QueryDocument + + Operation *ast.OperationDefinition + DisableIntrospection bool + Recover RecoverFunc + ResolverMiddleware FieldMiddleware + + Stats Stats +} + +func (c *OperationContext) Validate(ctx context.Context) error { + if c.Doc == nil { + return errors.New("field 'Doc'is required") + } + if c.RawQuery == "" { + return errors.New("field 'RawQuery' is required") + } + if c.Variables == nil { + c.Variables = make(map[string]interface{}) + } + if c.ResolverMiddleware == nil { + return errors.New("field 'ResolverMiddleware' is required") + } + if c.Recover == nil { + c.Recover = DefaultRecover + } + + return nil +} + +const operationCtx key = "operation_context" + +// Deprecated: Please update all references to GetOperationContext instead +func GetRequestContext(ctx context.Context) *RequestContext { + return GetOperationContext(ctx) +} + +func GetOperationContext(ctx context.Context) *OperationContext { + if val, ok := ctx.Value(operationCtx).(*OperationContext); ok && val != nil { + return val + } + panic("missing operation context") +} + +func WithOperationContext(ctx context.Context, rc *OperationContext) context.Context { + return context.WithValue(ctx, operationCtx, rc) +} + +// This is just a convenient wrapper method for CollectFields +func CollectFieldsCtx(ctx context.Context, satisfies []string) []CollectedField { + resctx := GetFieldContext(ctx) + return CollectFields(GetOperationContext(ctx), resctx.Field.Selections, satisfies) +} + +// CollectAllFields returns a slice of all GraphQL field names that were selected for the current resolver context. +// The slice will contain the unique set of all field names requested regardless of fragment type conditions. +func CollectAllFields(ctx context.Context) []string { + resctx := GetFieldContext(ctx) + collected := CollectFields(GetOperationContext(ctx), resctx.Field.Selections, nil) + uniq := make([]string, 0, len(collected)) +Next: + for _, f := range collected { + for _, name := range uniq { + if name == f.Name { + continue Next + } + } + uniq = append(uniq, f.Name) + } + return uniq +} + +// Errorf sends an error string to the client, passing it through the formatter. +// Deprecated: use graphql.AddErrorf(ctx, err) instead +func (c *OperationContext) Errorf(ctx context.Context, format string, args ...interface{}) { + AddErrorf(ctx, format, args...) +} + +// Error sends an error to the client, passing it through the formatter. +// Deprecated: use graphql.AddError(ctx, err) instead +func (c *OperationContext) Error(ctx context.Context, err error) { + AddError(ctx, err) +} diff --git a/graphql/context_operation_test.go b/graphql/context_operation_test.go new file mode 100644 index 00000000000..1086c237fc1 --- /dev/null +++ b/graphql/context_operation_test.go @@ -0,0 +1,66 @@ +package graphql + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/ast" +) + +func TestGetOperationContext(t *testing.T) { + rc := &OperationContext{} + require.Equal(t, rc, GetOperationContext(WithOperationContext(context.Background(), rc))) +} + +func TestCollectAllFields(t *testing.T) { + t.Run("collect fields", func(t *testing.T) { + ctx := testContext(ast.SelectionSet{ + &ast.Field{ + Name: "field", + }, + }) + s := CollectAllFields(ctx) + require.Equal(t, []string{"field"}, s) + }) + + t.Run("unique field names", func(t *testing.T) { + ctx := testContext(ast.SelectionSet{ + &ast.Field{ + Name: "field", + }, + &ast.Field{ + Name: "field", + Alias: "field alias", + }, + }) + s := CollectAllFields(ctx) + require.Equal(t, []string{"field"}, s) + }) + + t.Run("collect fragments", func(t *testing.T) { + ctx := testContext(ast.SelectionSet{ + &ast.Field{ + Name: "fieldA", + }, + &ast.InlineFragment{ + TypeCondition: "ExampleTypeA", + SelectionSet: ast.SelectionSet{ + &ast.Field{ + Name: "fieldA", + }, + }, + }, + &ast.InlineFragment{ + TypeCondition: "ExampleTypeB", + SelectionSet: ast.SelectionSet{ + &ast.Field{ + Name: "fieldB", + }, + }, + }, + }) + s := CollectAllFields(ctx) + require.Equal(t, []string{"fieldA", "fieldB"}, s) + }) +} diff --git a/graphql/context_response.go b/graphql/context_response.go new file mode 100644 index 00000000000..4031752b871 --- /dev/null +++ b/graphql/context_response.go @@ -0,0 +1,149 @@ +package graphql + +import ( + "context" + "fmt" + "sync" + + "github.com/vektah/gqlparser/gqlerror" +) + +type responseContext struct { + errorPresenter ErrorPresenterFunc + recover RecoverFunc + + errors gqlerror.List + errorsMu sync.Mutex + + extensions map[string]interface{} + extensionsMu sync.Mutex +} + +const resultCtx key = "result_context" + +func getResponseContext(ctx context.Context) *responseContext { + val, ok := ctx.Value(resultCtx).(*responseContext) + if !ok { + panic("missing response context") + } + return val +} + +func WithResponseContext(ctx context.Context, presenterFunc ErrorPresenterFunc, recoverFunc RecoverFunc) context.Context { + return context.WithValue(ctx, resultCtx, &responseContext{ + errorPresenter: presenterFunc, + recover: recoverFunc, + }) +} + +// AddErrorf writes a formatted error to the client, first passing it through the error presenter. +func AddErrorf(ctx context.Context, format string, args ...interface{}) { + c := getResponseContext(ctx) + + c.errorsMu.Lock() + defer c.errorsMu.Unlock() + + c.errors = append(c.errors, c.errorPresenter(ctx, fmt.Errorf(format, args...))) +} + +// AddError sends an error to the client, first passing it through the error presenter. +func AddError(ctx context.Context, err error) { + c := getResponseContext(ctx) + + c.errorsMu.Lock() + defer c.errorsMu.Unlock() + + c.errors = append(c.errors, c.errorPresenter(ctx, err)) +} + +func Recover(ctx context.Context, err interface{}) (userMessage error) { + c := getResponseContext(ctx) + return c.recover(ctx, err) +} + +// HasFieldError returns true if the given field has already errored +func HasFieldError(ctx context.Context, rctx *FieldContext) bool { + c := getResponseContext(ctx) + + c.errorsMu.Lock() + defer c.errorsMu.Unlock() + path := rctx.Path() + + for _, err := range c.errors { + if equalPath(err.Path, path) { + return true + } + } + return false +} + +// GetFieldErrors returns a list of errors that occurred in the given field +func GetFieldErrors(ctx context.Context, rctx *FieldContext) gqlerror.List { + c := getResponseContext(ctx) + + c.errorsMu.Lock() + defer c.errorsMu.Unlock() + path := rctx.Path() + + var errs gqlerror.List + for _, err := range c.errors { + if equalPath(err.Path, path) { + errs = append(errs, err) + } + } + return errs +} + +func GetErrors(ctx context.Context) gqlerror.List { + resCtx := getResponseContext(ctx) + resCtx.errorsMu.Lock() + defer resCtx.errorsMu.Unlock() + + if len(resCtx.errors) == 0 { + return nil + } + + errs := resCtx.errors + cpy := make(gqlerror.List, len(errs)) + for i := range errs { + errCpy := *errs[i] + cpy[i] = &errCpy + } + return cpy +} + +// RegisterExtension allows you to add a new extension into the graphql response +func RegisterExtension(ctx context.Context, key string, value interface{}) { + c := getResponseContext(ctx) + c.extensionsMu.Lock() + defer c.extensionsMu.Unlock() + + if c.extensions == nil { + c.extensions = make(map[string]interface{}) + } + + if _, ok := c.extensions[key]; ok { + panic(fmt.Errorf("extension already registered for key %s", key)) + } + + c.extensions[key] = value +} + +// GetExtensions returns any extensions registered in the current result context +func GetExtensions(ctx context.Context) map[string]interface{} { + ext := getResponseContext(ctx).extensions + if ext == nil { + return map[string]interface{}{} + } + + return ext +} + +func GetExtension(ctx context.Context, name string) interface{} { + ext := getResponseContext(ctx).extensions + if ext == nil { + return nil + } + + return ext[name] +} diff --git a/graphql/context_response_test.go b/graphql/context_response_test.go new file mode 100644 index 00000000000..59d80f4403a --- /dev/null +++ b/graphql/context_response_test.go @@ -0,0 +1,81 @@ +package graphql + +import ( + "context" + "errors" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/ast" + "github.com/vektah/gqlparser/gqlerror" +) + +func TestAddError(t *testing.T) { + ctx := WithResponseContext(context.Background(), DefaultErrorPresenter, nil) + + root := &FieldContext{ + Field: CollectedField{ + Field: &ast.Field{ + Alias: "foo", + }, + }, + } + ctx = WithFieldContext(ctx, root) + AddError(ctx, errors.New("foo1")) + AddError(ctx, errors.New("foo2")) + + index := 1 + child := &FieldContext{ + Parent: root, + Index: &index, + } + userProvidedPath := &FieldContext{ + Parent: child, + Field: CollectedField{ + Field: &ast.Field{ + Alias: "works", + }, + }, + } + + ctx = WithFieldContext(ctx, child) + AddError(ctx, errors.New("bar")) + AddError(ctx, &gqlerror.Error{ + Message: "foo3", + Path: append(child.Path(), "works"), + }) + + specs := []struct { + Name string + RCtx *FieldContext + Messages []string + }{ + { + Name: "with root FieldContext", + RCtx: root, + Messages: []string{"foo1", "foo2"}, + }, + { + Name: "with child FieldContext", + RCtx: child, + Messages: []string{"bar"}, + }, + { + Name: "with user provided path", + RCtx: userProvidedPath, + Messages: []string{"foo3"}, + }, + } + + for _, spec := range specs { + t.Run(spec.Name, func(t *testing.T) { + errList := GetFieldErrors(ctx, spec.RCtx) + require.Len(t, errList, len(spec.Messages)) + + for idx, err := range errList { + assert.Equal(t, spec.Messages[idx], err.Message) + } + }) + } +} diff --git a/graphql/context_test.go b/graphql/context_test.go deleted file mode 100644 index 85387e930df..00000000000 --- a/graphql/context_test.go +++ /dev/null @@ -1,168 +0,0 @@ -package graphql - -import ( - "context" - "errors" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/vektah/gqlparser/ast" - "github.com/vektah/gqlparser/gqlerror" -) - -func TestRequestContext_GetErrors(t *testing.T) { - c := &RequestContext{ - ErrorPresenter: DefaultErrorPresenter, - } - - ctx := context.Background() - - root := &ResolverContext{ - Field: CollectedField{ - Field: &ast.Field{ - Alias: "foo", - }, - }, - } - ctx = WithResolverContext(ctx, root) - c.Error(ctx, errors.New("foo1")) - c.Error(ctx, errors.New("foo2")) - - index := 1 - child := &ResolverContext{ - Parent: root, - Index: &index, - } - userProvidedPath := &ResolverContext{ - Parent: child, - Field: CollectedField{ - Field: &ast.Field{ - Alias: "works", - }, - }, - } - - ctx = WithResolverContext(ctx, child) - c.Error(ctx, errors.New("bar")) - c.Error(ctx, &gqlerror.Error{ - Message: "foo3", - Path: append(child.Path(), "works"), - }) - - specs := []struct { - Name string - RCtx *ResolverContext - Messages []string - }{ - { - Name: "with root ResolverContext", - RCtx: root, - Messages: []string{"foo1", "foo2"}, - }, - { - Name: "with child ResolverContext", - RCtx: child, - Messages: []string{"bar"}, - }, - { - Name: "with user provided path", - RCtx: userProvidedPath, - Messages: []string{"foo3"}, - }, - } - - for _, spec := range specs { - t.Run(spec.Name, func(t *testing.T) { - errList := c.GetErrors(spec.RCtx) - if assert.Equal(t, len(spec.Messages), len(errList)) { - for idx, err := range errList { - assert.Equal(t, spec.Messages[idx], err.Message) - } - } - }) - } -} - -func TestGetRequestContext(t *testing.T) { - require.Nil(t, GetRequestContext(context.Background())) - - rc := &RequestContext{} - require.Equal(t, rc, GetRequestContext(WithRequestContext(context.Background(), rc))) -} - -func TestGetResolverContext(t *testing.T) { - require.Nil(t, GetResolverContext(context.Background())) - - rc := &ResolverContext{} - require.Equal(t, rc, GetResolverContext(WithResolverContext(context.Background(), rc))) -} - -func testContext(sel ast.SelectionSet) context.Context { - - ctx := context.Background() - - rqCtx := &RequestContext{} - ctx = WithRequestContext(ctx, rqCtx) - - root := &ResolverContext{ - Field: CollectedField{ - Selections: sel, - }, - } - ctx = WithResolverContext(ctx, root) - - return ctx -} - -func TestCollectAllFields(t *testing.T) { - t.Run("collect fields", func(t *testing.T) { - ctx := testContext(ast.SelectionSet{ - &ast.Field{ - Name: "field", - }, - }) - s := CollectAllFields(ctx) - require.Equal(t, []string{"field"}, s) - }) - - t.Run("unique field names", func(t *testing.T) { - ctx := testContext(ast.SelectionSet{ - &ast.Field{ - Name: "field", - }, - &ast.Field{ - Name: "field", - Alias: "field alias", - }, - }) - s := CollectAllFields(ctx) - require.Equal(t, []string{"field"}, s) - }) - - t.Run("collect fragments", func(t *testing.T) { - ctx := testContext(ast.SelectionSet{ - &ast.Field{ - Name: "fieldA", - }, - &ast.InlineFragment{ - TypeCondition: "ExampleTypeA", - SelectionSet: ast.SelectionSet{ - &ast.Field{ - Name: "fieldA", - }, - }, - }, - &ast.InlineFragment{ - TypeCondition: "ExampleTypeB", - SelectionSet: ast.SelectionSet{ - &ast.Field{ - Name: "fieldB", - }, - }, - }, - }) - s := CollectAllFields(ctx) - require.Equal(t, []string{"fieldA", "fieldB"}, s) - }) -} diff --git a/graphql/error.go b/graphql/error.go index af8b4ce4088..a7a6769beda 100644 --- a/graphql/error.go +++ b/graphql/error.go @@ -6,7 +6,7 @@ import ( "github.com/vektah/gqlparser/gqlerror" ) -type ErrorPresenterFunc func(context.Context, error) *gqlerror.Error +type ErrorPresenterFunc func(ctx context.Context, err error) *gqlerror.Error type ExtendedError interface { Extensions() map[string]interface{} @@ -15,7 +15,7 @@ type ExtendedError interface { func DefaultErrorPresenter(ctx context.Context, err error) *gqlerror.Error { if gqlerr, ok := err.(*gqlerror.Error); ok { if gqlerr.Path == nil { - gqlerr.Path = GetResolverContext(ctx).Path() + gqlerr.Path = GetFieldContext(ctx).Path() } return gqlerr } @@ -27,7 +27,7 @@ func DefaultErrorPresenter(ctx context.Context, err error) *gqlerror.Error { return &gqlerror.Error{ Message: err.Error(), - Path: GetResolverContext(ctx).Path(), + Path: GetFieldContext(ctx).Path(), Extensions: extensions, } } diff --git a/graphql/exec.go b/graphql/executable_schema.go similarity index 88% rename from graphql/exec.go rename to graphql/executable_schema.go index 3e00a4d57b1..7f0df9104ef 100644 --- a/graphql/exec.go +++ b/graphql/executable_schema.go @@ -1,3 +1,5 @@ +//go:generate go run github.com/matryer/moq -out executable_schema_mock.go . ExecutableSchema + package graphql import ( @@ -11,19 +13,17 @@ type ExecutableSchema interface { Schema() *ast.Schema Complexity(typeName, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) - Query(ctx context.Context, op *ast.OperationDefinition) *Response - Mutation(ctx context.Context, op *ast.OperationDefinition) *Response - Subscription(ctx context.Context, op *ast.OperationDefinition) func() *Response + Exec(ctx context.Context) ResponseHandler } // CollectFields returns the set of fields from an ast.SelectionSet where all collected fields satisfy at least one of the GraphQL types // passed through satisfies. Providing an empty or nil slice for satisfies will return collect all fields regardless of fragment // type conditions. -func CollectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []string) []CollectedField { +func CollectFields(reqCtx *OperationContext, selSet ast.SelectionSet, satisfies []string) []CollectedField { return collectFields(reqCtx, selSet, satisfies, map[string]bool{}) } -func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []string, visited map[string]bool) []CollectedField { +func collectFields(reqCtx *OperationContext, selSet ast.SelectionSet, satisfies []string, visited map[string]bool) []CollectedField { groupedFields := make([]CollectedField, 0, len(selSet)) for _, sel := range selSet { diff --git a/graphql/executable_schema_mock.go b/graphql/executable_schema_mock.go new file mode 100644 index 00000000000..c099de793e9 --- /dev/null +++ b/graphql/executable_schema_mock.go @@ -0,0 +1,175 @@ +// Code generated by moq; DO NOT EDIT. +// github.com/matryer/moq + +package graphql + +import ( + "context" + "github.com/vektah/gqlparser/ast" + "sync" +) + +var ( + lockExecutableSchemaMockComplexity sync.RWMutex + lockExecutableSchemaMockExec sync.RWMutex + lockExecutableSchemaMockSchema sync.RWMutex +) + +// Ensure, that ExecutableSchemaMock does implement ExecutableSchema. +// If this is not the case, regenerate this file with moq. +var _ ExecutableSchema = &ExecutableSchemaMock{} + +// ExecutableSchemaMock is a mock implementation of ExecutableSchema. +// +// func TestSomethingThatUsesExecutableSchema(t *testing.T) { +// +// // make and configure a mocked ExecutableSchema +// mockedExecutableSchema := &ExecutableSchemaMock{ +// ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) { +// panic("mock out the Complexity method") +// }, +// ExecFunc: func(ctx context.Context) ResponseHandler { +// panic("mock out the Exec method") +// }, +// SchemaFunc: func() *ast.Schema { +// panic("mock out the Schema method") +// }, +// } +// +// // use mockedExecutableSchema in code that requires ExecutableSchema +// // and then make assertions. +// +// } +type ExecutableSchemaMock struct { + // ComplexityFunc mocks the Complexity method. + ComplexityFunc func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) + + // ExecFunc mocks the Exec method. + ExecFunc func(ctx context.Context) ResponseHandler + + // SchemaFunc mocks the Schema method. + SchemaFunc func() *ast.Schema + + // calls tracks calls to the methods. + calls struct { + // Complexity holds details about calls to the Complexity method. + Complexity []struct { + // TypeName is the typeName argument value. + TypeName string + // FieldName is the fieldName argument value. + FieldName string + // ChildComplexity is the childComplexity argument value. + ChildComplexity int + // Args is the args argument value. + Args map[string]interface{} + } + // Exec holds details about calls to the Exec method. + Exec []struct { + // Ctx is the ctx argument value. + Ctx context.Context + } + // Schema holds details about calls to the Schema method. + Schema []struct { + } + } +} + +// Complexity calls ComplexityFunc. +func (mock *ExecutableSchemaMock) Complexity(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) { + if mock.ComplexityFunc == nil { + panic("ExecutableSchemaMock.ComplexityFunc: method is nil but ExecutableSchema.Complexity was just called") + } + callInfo := struct { + TypeName string + FieldName string + ChildComplexity int + Args map[string]interface{} + }{ + TypeName: typeName, + FieldName: fieldName, + ChildComplexity: childComplexity, + Args: args, + } + lockExecutableSchemaMockComplexity.Lock() + mock.calls.Complexity = append(mock.calls.Complexity, callInfo) + lockExecutableSchemaMockComplexity.Unlock() + return mock.ComplexityFunc(typeName, fieldName, childComplexity, args) +} + +// ComplexityCalls gets all the calls that were made to Complexity. +// Check the length with: +// len(mockedExecutableSchema.ComplexityCalls()) +func (mock *ExecutableSchemaMock) ComplexityCalls() []struct { + TypeName string + FieldName string + ChildComplexity int + Args map[string]interface{} +} { + var calls []struct { + TypeName string + FieldName string + ChildComplexity int + Args map[string]interface{} + } + lockExecutableSchemaMockComplexity.RLock() + calls = mock.calls.Complexity + lockExecutableSchemaMockComplexity.RUnlock() + return calls +} + +// Exec calls ExecFunc. +func (mock *ExecutableSchemaMock) Exec(ctx context.Context) ResponseHandler { + if mock.ExecFunc == nil { + panic("ExecutableSchemaMock.ExecFunc: method is nil but ExecutableSchema.Exec was just called") + } + callInfo := struct { + Ctx context.Context + }{ + Ctx: ctx, + } + lockExecutableSchemaMockExec.Lock() + mock.calls.Exec = append(mock.calls.Exec, callInfo) + lockExecutableSchemaMockExec.Unlock() + return mock.ExecFunc(ctx) +} + +// ExecCalls gets all the calls that were made to Exec. +// Check the length with: +// len(mockedExecutableSchema.ExecCalls()) +func (mock *ExecutableSchemaMock) ExecCalls() []struct { + Ctx context.Context +} { + var calls []struct { + Ctx context.Context + } + lockExecutableSchemaMockExec.RLock() + calls = mock.calls.Exec + lockExecutableSchemaMockExec.RUnlock() + return calls +} + +// Schema calls SchemaFunc. +func (mock *ExecutableSchemaMock) Schema() *ast.Schema { + if mock.SchemaFunc == nil { + panic("ExecutableSchemaMock.SchemaFunc: method is nil but ExecutableSchema.Schema was just called") + } + callInfo := struct { + }{} + lockExecutableSchemaMockSchema.Lock() + mock.calls.Schema = append(mock.calls.Schema, callInfo) + lockExecutableSchemaMockSchema.Unlock() + return mock.SchemaFunc() +} + +// SchemaCalls gets all the calls that were made to Schema. +// Check the length with: +// len(mockedExecutableSchema.SchemaCalls()) +func (mock *ExecutableSchemaMock) SchemaCalls() []struct { +} { + var calls []struct { + } + lockExecutableSchemaMockSchema.RLock() + calls = mock.calls.Schema + lockExecutableSchemaMockSchema.RUnlock() + return calls +} diff --git a/graphql/handler.go b/graphql/handler.go new file mode 100644 index 00000000000..e9c95b442ff --- /dev/null +++ b/graphql/handler.go @@ -0,0 +1,121 @@ +package graphql + +import ( + "context" + "net/http" + "strconv" + "strings" + + "github.com/vektah/gqlparser/gqlerror" +) + +type ( + OperationMiddleware func(ctx context.Context, next OperationHandler) ResponseHandler + OperationHandler func(ctx context.Context) ResponseHandler + + ResponseHandler func(ctx context.Context) *Response + ResponseMiddleware func(ctx context.Context, next ResponseHandler) *Response + + Resolver func(ctx context.Context) (res interface{}, err error) + FieldMiddleware func(ctx context.Context, next Resolver) (res interface{}, err error) + + RawParams struct { + Query string `json:"query"` + OperationName string `json:"operationName"` + Variables map[string]interface{} `json:"variables"` + Extensions map[string]interface{} `json:"extensions"` + } + + GraphExecutor interface { + CreateOperationContext(ctx context.Context, params *RawParams) (*OperationContext, gqlerror.List) + DispatchOperation(ctx context.Context, rc *OperationContext) (ResponseHandler, context.Context) + DispatchError(ctx context.Context, list gqlerror.List) *Response + } + + // HandlerExtension adds functionality to the http handler. See the list of possible hook points below + // Its important to understand the lifecycle of a graphql request and the terminology we use in gqlgen + // before working with these + // + // +--- REQUEST POST /graphql --------------------------------------------+ + // | +- OPERATION query OpName { viewer { name } } -----------------------+ | + // | | RESPONSE { "data": { "viewer": { "name": "bob" } } } | | + // | +- OPERATION subscription OpName2 { chat { message } } --------------+ | + // | | RESPONSE { "data": { "chat": { "message": "hello" } } } | | + // | | RESPONSE { "data": { "chat": { "message": "byee" } } } | | + // | +--------------------------------------------------------------------+ | + // +------------------------------------------------------------------------+ + HandlerExtension interface { + // ExtensionName should be a CamelCase string version of the extension which may be shown in stats and logging. + ExtensionName() string + // Validate is called when adding an extension to the server, it allows validation against the servers schema. + Validate(schema ExecutableSchema) error + } + + // OperationParameterMutator is called before creating a request context. allows manipulating the raw query + // on the way in. + OperationParameterMutator interface { + MutateOperationParameters(ctx context.Context, request *RawParams) *gqlerror.Error + } + + // OperationContextMutator is called after creating the request context, but before executing the root resolver. + OperationContextMutator interface { + MutateOperationContext(ctx context.Context, rc *OperationContext) *gqlerror.Error + } + + // OperationInterceptor is called for each incoming query, for basic requests the writer will be invoked once, + // for subscriptions it will be invoked multiple times. + OperationInterceptor interface { + InterceptOperation(ctx context.Context, next OperationHandler) ResponseHandler + } + + // ResponseInterceptor is called around each graphql operation response. This can be called many times for a single + // operation the case of subscriptions. + ResponseInterceptor interface { + InterceptResponse(ctx context.Context, next ResponseHandler) *Response + } + + // FieldInterceptor called around each field + FieldInterceptor interface { + InterceptField(ctx context.Context, next Resolver) (res interface{}, err error) + } + + // Transport provides support for different wire level encodings of graphql requests, eg Form, Get, Post, Websocket + Transport interface { + Supports(r *http.Request) bool + Do(w http.ResponseWriter, r *http.Request, exec GraphExecutor) + } +) + +type Status int + +func (p *RawParams) AddUpload(upload Upload, key, path string) *gqlerror.Error { + if !strings.HasPrefix(path, "variables.") { + return gqlerror.Errorf("invalid operations paths for key %s", key) + } + + var ptr interface{} = p.Variables + parts := strings.Split(path, ".") + + // skip the first part (variables) because we started there + for i, p := range parts[1:] { + last := i == len(parts)-2 + if ptr == nil { + return gqlerror.Errorf("path is missing \"variables.\" prefix, key: %s, path: %s", key, path) + } + if index, parseNbrErr := strconv.Atoi(p); parseNbrErr == nil { + if last { + ptr.([]interface{})[index] = upload + } else { + ptr = ptr.([]interface{})[index] + } + } else { + if last { + ptr.(map[string]interface{})[p] = upload + } else { + ptr = ptr.(map[string]interface{})[p] + } + } + } + + return nil +} diff --git a/graphql/handler/apollotracing/tracer.go b/graphql/handler/apollotracing/tracer.go new file mode 100644 index 00000000000..b4b0cb312f9 --- /dev/null +++ b/graphql/handler/apollotracing/tracer.go @@ -0,0 +1,116 @@ +package apollotracing + +import ( + "context" + "sync" + "time" + + "github.com/99designs/gqlgen/graphql" +) + +type ( + Tracer struct{} + + TracingExtension struct { + mu sync.Mutex + Version int `json:"version"` + StartTime time.Time `json:"startTime"` + EndTime time.Time `json:"endTime"` + Duration time.Duration `json:"duration"` + Parsing Span `json:"parsing"` + Validation Span `json:"validation"` + Execution struct { + Resolvers []ResolverExecution `json:"resolvers"` + } `json:"execution"` + } + + Span struct { + StartOffset time.Duration `json:"startOffset"` + Duration time.Duration `json:"duration"` + } + + ResolverExecution struct { + Path []interface{} `json:"path"` + ParentType string `json:"parentType"` + FieldName string `json:"fieldName"` + ReturnType string `json:"returnType"` + StartOffset time.Duration `json:"startOffset"` + Duration time.Duration `json:"duration"` + } +) + +var _ interface { + graphql.HandlerExtension + graphql.ResponseInterceptor + graphql.FieldInterceptor +} = Tracer{} + +func (a Tracer) ExtensionName() string { + return "ApolloTracing" +} + +func (a Tracer) Validate(schema graphql.ExecutableSchema) error { + return nil +} + +func (a Tracer) InterceptField(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + rc := graphql.GetOperationContext(ctx) + td, ok := graphql.GetExtension(ctx, "tracing").(*TracingExtension) + if !ok { + panic("missing tracing extension") + } + + start := graphql.Now() + + defer func() { + td.mu.Lock() + defer td.mu.Unlock() + fc := graphql.GetFieldContext(ctx) + + end := graphql.Now() + + td.Execution.Resolvers = append(td.Execution.Resolvers, ResolverExecution{ + Path: fc.Path(), + ParentType: fc.Object, + FieldName: fc.Field.Name, + ReturnType: fc.Field.Definition.Type.String(), + StartOffset: start.Sub(rc.Stats.OperationStart), + Duration: end.Sub(start), + }) + }() + + return next(ctx) +} + +func (a Tracer) InterceptResponse(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + rc := graphql.GetOperationContext(ctx) + + start := rc.Stats.OperationStart + + td := &TracingExtension{ + Version: 1, + StartTime: start, + Parsing: Span{ + StartOffset: rc.Stats.Parsing.Start.Sub(start), + Duration: rc.Stats.Parsing.End.Sub(rc.Stats.Parsing.Start), + }, + + Validation: Span{ + StartOffset: rc.Stats.Validation.Start.Sub(start), + Duration: rc.Stats.Validation.End.Sub(rc.Stats.Validation.Start), + }, + + Execution: struct { + Resolvers []ResolverExecution `json:"resolvers"` + }{}, + } + + graphql.RegisterExtension(ctx, "tracing", td) + resp := next(ctx) + + end := graphql.Now() + td.EndTime = end + td.Duration = end.Sub(start) + + return resp +} diff --git a/graphql/handler/apollotracing/tracer_test.go b/graphql/handler/apollotracing/tracer_test.go new file mode 100644 index 00000000000..f94070c33d2 --- /dev/null +++ b/graphql/handler/apollotracing/tracer_test.go @@ -0,0 +1,81 @@ +package apollotracing_test + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/99designs/gqlgen/graphql/handler/apollotracing" + "github.com/99designs/gqlgen/graphql/handler/extension" + "github.com/99designs/gqlgen/graphql/handler/lru" + "github.com/99designs/gqlgen/graphql/handler/testserver" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/gqlerror" +) + +func TestApolloTracing(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.POST{}) + h.Use(apollotracing.Tracer{}) + + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }"}`) + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + var respData struct { + Extensions struct { + Tracing apollotracing.TracingExtension `json:"tracing"` + } `json:"extensions"` + } + require.NoError(t, json.Unmarshal(resp.Body.Bytes(), &respData)) + + tracing := &respData.Extensions.Tracing + + require.EqualValues(t, 1, tracing.Version) + + require.EqualValues(t, 0, tracing.StartTime.UnixNano()) + require.EqualValues(t, 700, tracing.EndTime.UnixNano()) + require.EqualValues(t, 700, tracing.Duration) + + require.EqualValues(t, 100, tracing.Parsing.StartOffset) + require.EqualValues(t, 100, tracing.Parsing.Duration) + + require.EqualValues(t, 300, tracing.Validation.StartOffset) + require.EqualValues(t, 100, tracing.Validation.Duration) + + require.EqualValues(t, 500, tracing.Execution.Resolvers[0].StartOffset) + require.EqualValues(t, 100, tracing.Execution.Resolvers[0].Duration) + require.EqualValues(t, []interface{}{"name"}, tracing.Execution.Resolvers[0].Path) + require.EqualValues(t, "Query", tracing.Execution.Resolvers[0].ParentType) + require.EqualValues(t, "name", tracing.Execution.Resolvers[0].FieldName) + require.EqualValues(t, "String!", tracing.Execution.Resolvers[0].ReturnType) +} + +func TestApolloTracing_withFail(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.POST{}) + h.Use(extension.AutomaticPersistedQuery{Cache: lru.New(100)}) + h.Use(apollotracing.Tracer{}) + + resp := doRequest(h, "POST", "/graphql", `{"operationName":"A","extensions":{"persistedQuery":{"version":1,"sha256Hash":"338bbc16ac780daf81845339fbf0342061c1e9d2b702c96d3958a13a557083a6"}}}`) + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + b := resp.Body.Bytes() + t.Log(string(b)) + var respData struct { + Errors gqlerror.List + } + require.NoError(t, json.Unmarshal(b, &respData)) + require.Equal(t, 1, len(respData.Errors)) + require.Equal(t, "PersistedQueryNotFound", respData.Errors[0].Message) +} + +func doRequest(handler http.Handler, method string, target string, body string) *httptest.ResponseRecorder { + r := httptest.NewRequest(method, target, strings.NewReader(body)) + r.Header.Set("Content-Type", "application/json") + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w +} diff --git a/graphql/handler/executor.go b/graphql/handler/executor.go new file mode 100644 index 00000000000..e3b751a2f38 --- /dev/null +++ b/graphql/handler/executor.go @@ -0,0 +1,206 @@ +package handler + +import ( + "context" + + "github.com/99designs/gqlgen/graphql" + "github.com/vektah/gqlparser/ast" + "github.com/vektah/gqlparser/gqlerror" + "github.com/vektah/gqlparser/parser" + "github.com/vektah/gqlparser/validator" +) + +type executor struct { + operationMiddleware graphql.OperationMiddleware + responseMiddleware graphql.ResponseMiddleware + fieldMiddleware graphql.FieldMiddleware + operationParameterMutators []graphql.OperationParameterMutator + operationContextMutators []graphql.OperationContextMutator + server *Server +} + +var _ graphql.GraphExecutor = executor{} + +func newExecutor(s *Server) executor { + e := executor{ + server: s, + } + e.operationMiddleware = func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + return next(ctx) + } + e.responseMiddleware = func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + return next(ctx) + } + e.fieldMiddleware = func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + return next(ctx) + } + + // this loop goes backwards so the first extension is the outer most middleware and runs first. + for i := len(s.extensions) - 1; i >= 0; i-- { + p := s.extensions[i] + if p, ok := p.(graphql.OperationInterceptor); ok { + previous := e.operationMiddleware + e.operationMiddleware = func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + return p.InterceptOperation(ctx, func(ctx context.Context) graphql.ResponseHandler { + return previous(ctx, next) + }) + } + } + + if p, ok := p.(graphql.ResponseInterceptor); ok { + previous := e.responseMiddleware + e.responseMiddleware = func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + return p.InterceptResponse(ctx, func(ctx context.Context) *graphql.Response { + return previous(ctx, next) + }) + } + } + + if p, ok := p.(graphql.FieldInterceptor); ok { + previous := e.fieldMiddleware + e.fieldMiddleware = func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + return p.InterceptField(ctx, func(ctx context.Context) (res interface{}, err error) { + return previous(ctx, next) + }) + } + } + } + + for _, p := range s.extensions { + if p, ok := p.(graphql.OperationParameterMutator); ok { + e.operationParameterMutators = append(e.operationParameterMutators, p) + } + + if p, ok := p.(graphql.OperationContextMutator); ok { + e.operationContextMutators = append(e.operationContextMutators, p) + } + + } + + return e +} + +func (e executor) DispatchOperation(ctx context.Context, rc *graphql.OperationContext) (h graphql.ResponseHandler, resctx context.Context) { + ctx = graphql.WithOperationContext(ctx, rc) + + var innerCtx context.Context + res := e.operationMiddleware(ctx, func(ctx context.Context) graphql.ResponseHandler { + innerCtx = ctx + + tmpResponseContext := graphql.WithResponseContext(ctx, e.server.errorPresenter, e.server.recoverFunc) + responses := e.server.es.Exec(tmpResponseContext) + if errs := graphql.GetErrors(tmpResponseContext); errs != nil { + return graphql.OneShot(&graphql.Response{Errors: errs}) + } + + return func(ctx context.Context) *graphql.Response { + ctx = graphql.WithResponseContext(ctx, e.server.errorPresenter, e.server.recoverFunc) + resp := e.responseMiddleware(ctx, func(ctx context.Context) *graphql.Response { + resp := responses(ctx) + if resp == nil { + return nil + } + resp.Extensions = graphql.GetExtensions(ctx) + return resp + }) + if resp == nil { + return nil + } + + resp.Errors = append(resp.Errors, graphql.GetErrors(ctx)...) + return resp + } + }) + + return res, innerCtx +} + +func (e executor) CreateOperationContext(ctx context.Context, params *graphql.RawParams) (*graphql.OperationContext, gqlerror.List) { + rc := &graphql.OperationContext{ + DisableIntrospection: true, + Recover: graphql.DefaultRecover, + ResolverMiddleware: e.fieldMiddleware, + Stats: graphql.Stats{OperationStart: graphql.GetStartTime(ctx)}, + } + ctx = graphql.WithOperationContext(ctx, rc) + + for _, p := range e.operationParameterMutators { + if err := p.MutateOperationParameters(ctx, params); err != nil { + return rc, gqlerror.List{err} + } + } + + rc.RawQuery = params.Query + rc.OperationName = params.OperationName + + var listErr gqlerror.List + rc.Doc, listErr = e.parseQuery(ctx, &rc.Stats, params.Query) + if len(listErr) != 0 { + return rc, listErr + } + + rc.Operation = rc.Doc.Operations.ForName(params.OperationName) + if rc.Operation == nil { + return rc, gqlerror.List{gqlerror.Errorf("operation %s not found", params.OperationName)} + } + + var err *gqlerror.Error + rc.Variables, err = validator.VariableValues(e.server.es.Schema(), rc.Operation, params.Variables) + if err != nil { + return rc, gqlerror.List{err} + } + rc.Stats.Validation.End = graphql.Now() + + for _, p := range e.operationContextMutators { + if err := p.MutateOperationContext(ctx, rc); err != nil { + return rc, gqlerror.List{err} + } + } + + return rc, nil +} + +func (e executor) DispatchError(ctx context.Context, list gqlerror.List) *graphql.Response { + ctx = graphql.WithResponseContext(ctx, e.server.errorPresenter, e.server.recoverFunc) + resp := e.responseMiddleware(ctx, func(ctx context.Context) *graphql.Response { + resp := &graphql.Response{ + Errors: list, + } + resp.Extensions = graphql.GetExtensions(ctx) + return resp + }) + + return resp +} + +// parseQuery decodes the incoming query and validates it, pulling from cache if present. +// +// NOTE: This should NOT look at variables, they will change per request. It should only parse and validate +// the raw query string. +func (e executor) parseQuery(ctx context.Context, stats *graphql.Stats, query string) (*ast.QueryDocument, gqlerror.List) { + stats.Parsing.Start = graphql.Now() + + if doc, ok := e.server.queryCache.Get(query); ok { + now := graphql.Now() + + stats.Parsing.End = now + stats.Validation.Start = now + return doc.(*ast.QueryDocument), nil + } + + doc, err := parser.ParseQuery(&ast.Source{Input: query}) + if err != nil { + return nil, gqlerror.List{err} + } + stats.Parsing.End = graphql.Now() + + stats.Validation.Start = graphql.Now() + listErr := validator.Validate(e.server.es.Schema(), doc) + if len(listErr) != 0 { + return nil, listErr + } + + e.server.queryCache.Add(query, doc) + + return doc, nil +} diff --git a/graphql/handler/extension/apq.go b/graphql/handler/extension/apq.go new file mode 100644 index 00000000000..4511094527c --- /dev/null +++ b/graphql/handler/extension/apq.go @@ -0,0 +1,107 @@ +package extension + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "fmt" + + "github.com/vektah/gqlparser/gqlerror" + + "github.com/99designs/gqlgen/graphql" + "github.com/mitchellh/mapstructure" +) + +const errPersistedQueryNotFound = "PersistedQueryNotFound" + +// AutomaticPersistedQuery saves client upload by optimistically sending only the hashes of queries, if the server +// does not yet know what the query is for the hash it will respond telling the client to send the query along with the +// hash in the next request. +// see https://github.com/apollographql/apollo-link-persisted-queries +type AutomaticPersistedQuery struct { + Cache graphql.Cache +} + +type ApqStats struct { + // The hash of the incoming query + Hash string + + // SentQuery is true if the incoming request sent the full query + SentQuery bool +} + +const apqExtension = "APQ" + +var _ interface { + graphql.OperationParameterMutator + graphql.HandlerExtension +} = AutomaticPersistedQuery{} + +func (a AutomaticPersistedQuery) ExtensionName() string { + return "AutomaticPersistedQuery" +} + +func (a AutomaticPersistedQuery) Validate(schema graphql.ExecutableSchema) error { + if a.Cache == nil { + return fmt.Errorf("AutomaticPersistedQuery.Cache can not be nil") + } + return nil +} + +func (a AutomaticPersistedQuery) MutateOperationParameters(ctx context.Context, rawParams *graphql.RawParams) *gqlerror.Error { + if rawParams.Extensions["persistedQuery"] == nil { + return nil + } + + var extension struct { + Sha256 string `mapstructure:"sha256Hash"` + Version int64 `mapstructure:"version"` + } + + if err := mapstructure.Decode(rawParams.Extensions["persistedQuery"], &extension); err != nil { + return gqlerror.Errorf("invalid APQ extension data") + } + + if extension.Version != 1 { + return gqlerror.Errorf("unsupported APQ version") + } + + fullQuery := false + if rawParams.Query == "" { + // client sent optimistic query hash without query string, get it from the cache + query, ok := a.Cache.Get(extension.Sha256) + if !ok { + return gqlerror.Errorf(errPersistedQueryNotFound) + } + rawParams.Query = query.(string) + } else { + // client sent optimistic query hash with query string, verify and store it + if computeQueryHash(rawParams.Query) != extension.Sha256 { + return gqlerror.Errorf("provided APQ hash does not match query") + } + a.Cache.Add(extension.Sha256, rawParams.Query) + fullQuery = true + } + + graphql.GetOperationContext(ctx).Stats.SetExtension(apqExtension, &ApqStats{ + Hash: extension.Sha256, + SentQuery: fullQuery, + }) + + return nil +} + +func GetApqStats(ctx context.Context) *ApqStats { + rc := graphql.GetOperationContext(ctx) + if rc == nil { + return nil + } + + s, _ := rc.Stats.GetExtension(apqExtension).(*ApqStats) + return s +} + +func computeQueryHash(query string) string { + b := sha256.Sum256([]byte(query)) + return hex.EncodeToString(b[:]) +} diff --git a/graphql/handler/extension/apq_test.go b/graphql/handler/extension/apq_test.go new file mode 100644 index 00000000000..66970c62e9c --- /dev/null +++ b/graphql/handler/extension/apq_test.go @@ -0,0 +1,167 @@ +package extension_test + +import ( + "context" + "net/http" + "testing" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler/extension" + "github.com/99designs/gqlgen/graphql/handler/testserver" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/stretchr/testify/require" +) + +func TestAPQIntegration(t *testing.T) { + h := testserver.New() + h.Use(&extension.AutomaticPersistedQuery{Cache: graphql.MapCache{}}) + h.AddTransport(&transport.POST{}) + + var stats *extension.ApqStats + h.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + stats = extension.GetApqStats(ctx) + return next(ctx) + }) + + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }","extensions":{"persistedQuery":{"version":1,"sha256Hash":"30166fc3298853f22709fce1e4a00e98f1b6a3160eaaaf9cb3b7db6a16073b07"}}}`) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + + require.NotNil(t, stats) + require.True(t, stats.SentQuery) + require.Equal(t, "30166fc3298853f22709fce1e4a00e98f1b6a3160eaaaf9cb3b7db6a16073b07", stats.Hash) +} + +func TestAPQ(t *testing.T) { + const query = "{ me { name } }" + const hash = "b8d9506e34c83b0e53c2aa463624fcea354713bc38f95276e6f0bd893ffb5b88" + + t.Run("with query and no hash", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Query: "original query", + } + err := extension.AutomaticPersistedQuery{graphql.MapCache{}}.MutateOperationParameters(ctx, params) + require.Nil(t, err) + + require.Equal(t, "original query", params.Query) + }) + + t.Run("with hash miss and no query", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Extensions: map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "sha256Hash": hash, + "version": 1, + }, + }, + } + + err := extension.AutomaticPersistedQuery{graphql.MapCache{}}.MutateOperationParameters(ctx, params) + require.Equal(t, err.Message, "PersistedQueryNotFound") + }) + + t.Run("with hash miss and query", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Query: query, + Extensions: map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "sha256Hash": hash, + "version": 1, + }, + }, + } + cache := graphql.MapCache{} + err := extension.AutomaticPersistedQuery{cache}.MutateOperationParameters(ctx, params) + require.Nil(t, err) + + require.Equal(t, "{ me { name } }", params.Query) + require.Equal(t, "{ me { name } }", cache[hash]) + }) + + t.Run("with hash miss and query", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Query: query, + Extensions: map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "sha256Hash": hash, + "version": 1, + }, + }, + } + cache := graphql.MapCache{} + err := extension.AutomaticPersistedQuery{cache}.MutateOperationParameters(ctx, params) + require.Nil(t, err) + + require.Equal(t, "{ me { name } }", params.Query) + require.Equal(t, "{ me { name } }", cache[hash]) + }) + + t.Run("with hash hit and no query", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Extensions: map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "sha256Hash": hash, + "version": 1, + }, + }, + } + cache := graphql.MapCache{ + hash: query, + } + err := extension.AutomaticPersistedQuery{cache}.MutateOperationParameters(ctx, params) + require.Nil(t, err) + + require.Equal(t, "{ me { name } }", params.Query) + }) + + t.Run("with malformed extension payload", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Extensions: map[string]interface{}{ + "persistedQuery": "asdf", + }, + } + + err := extension.AutomaticPersistedQuery{graphql.MapCache{}}.MutateOperationParameters(ctx, params) + require.Equal(t, err.Message, "invalid APQ extension data") + }) + + t.Run("with invalid extension version", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Extensions: map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "version": 2, + }, + }, + } + err := extension.AutomaticPersistedQuery{graphql.MapCache{}}.MutateOperationParameters(ctx, params) + require.Equal(t, err.Message, "unsupported APQ version") + }) + + t.Run("with hash mismatch", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Query: query, + Extensions: map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "sha256Hash": "badhash", + "version": 1, + }, + }, + } + + err := extension.AutomaticPersistedQuery{graphql.MapCache{}}.MutateOperationParameters(ctx, params) + require.Equal(t, err.Message, "provided APQ hash does not match query") + }) +} + +func newOC() context.Context { + oc := &graphql.OperationContext{} + return graphql.WithOperationContext(context.Background(), oc) +} diff --git a/graphql/handler/extension/complexity.go b/graphql/handler/extension/complexity.go new file mode 100644 index 00000000000..8fdb348252e --- /dev/null +++ b/graphql/handler/extension/complexity.go @@ -0,0 +1,83 @@ +package extension + +import ( + "context" + "fmt" + + "github.com/99designs/gqlgen/complexity" + "github.com/99designs/gqlgen/graphql" + "github.com/vektah/gqlparser/gqlerror" +) + +// ComplexityLimit allows you to define a limit on query complexity +// +// If a query is submitted that exceeds the limit, a 422 status code will be returned. +type ComplexityLimit struct { + Func func(ctx context.Context, rc *graphql.OperationContext) int + + es graphql.ExecutableSchema +} + +var _ interface { + graphql.OperationContextMutator + graphql.HandlerExtension +} = &ComplexityLimit{} + +const complexityExtension = "ComplexityLimit" + +type ComplexityStats struct { + // The calculated complexity for this request + Complexity int + + // The complexity limit for this request returned by the extension func + ComplexityLimit int +} + +// FixedComplexityLimit sets a complexity limit that does not change +func FixedComplexityLimit(limit int) *ComplexityLimit { + return &ComplexityLimit{ + Func: func(ctx context.Context, rc *graphql.OperationContext) int { + return limit + }, + } +} + +func (c ComplexityLimit) ExtensionName() string { + return complexityExtension +} + +func (c *ComplexityLimit) Validate(schema graphql.ExecutableSchema) error { + if c.Func == nil { + return fmt.Errorf("ComplexityLimit func can not be nil") + } + c.es = schema + return nil +} + +func (c ComplexityLimit) MutateOperationContext(ctx context.Context, rc *graphql.OperationContext) *gqlerror.Error { + op := rc.Doc.Operations.ForName(rc.OperationName) + complexity := complexity.Calculate(c.es, op, rc.Variables) + + limit := c.Func(ctx, rc) + + rc.Stats.SetExtension(complexityExtension, &ComplexityStats{ + Complexity: complexity, + ComplexityLimit: limit, + }) + + if complexity > limit { + return gqlerror.Errorf("operation has complexity %d, which exceeds the limit of %d", complexity, limit) + } + + return nil +} + +func GetComplexityStats(ctx context.Context) *ComplexityStats { + rc := graphql.GetOperationContext(ctx) + if rc == nil { + return nil + } + + s, _ := rc.Stats.GetExtension(complexityExtension).(*ComplexityStats) + return s +} diff --git a/graphql/handler/extension/complexity_test.go b/graphql/handler/extension/complexity_test.go new file mode 100644 index 00000000000..7622ebff98d --- /dev/null +++ b/graphql/handler/extension/complexity_test.go @@ -0,0 +1,107 @@ +package extension_test + +import ( + "context" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler/extension" + "github.com/99designs/gqlgen/graphql/handler/testserver" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/stretchr/testify/require" +) + +func TestHandlerComplexity(t *testing.T) { + h := testserver.New() + h.Use(&extension.ComplexityLimit{ + Func: func(ctx context.Context, rc *graphql.OperationContext) int { + if rc.RawQuery == "{ ok: name }" { + return 4 + } + return 2 + }, + }) + h.AddTransport(&transport.POST{}) + var stats *extension.ComplexityStats + h.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + stats = extension.GetComplexityStats(ctx) + return next(ctx) + }) + + t.Run("below complexity limit", func(t *testing.T) { + stats = nil + h.SetCalculatedComplexity(2) + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }"}`) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + + require.Equal(t, 2, stats.ComplexityLimit) + require.Equal(t, 2, stats.Complexity) + }) + + t.Run("above complexity limit", func(t *testing.T) { + stats = nil + h.SetCalculatedComplexity(4) + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }"}`) + require.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"operation has complexity 4, which exceeds the limit of 2"}],"data":null}`, resp.Body.String()) + + require.Equal(t, 2, stats.ComplexityLimit) + require.Equal(t, 4, stats.Complexity) + }) + + t.Run("within dynamic complexity limit", func(t *testing.T) { + stats = nil + h.SetCalculatedComplexity(4) + resp := doRequest(h, "POST", "/graphql", `{"query":"{ ok: name }"}`) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + + require.Equal(t, 4, stats.ComplexityLimit) + require.Equal(t, 4, stats.Complexity) + }) +} + +func TestFixedComplexity(t *testing.T) { + h := testserver.New() + h.Use(extension.FixedComplexityLimit(2)) + h.AddTransport(&transport.POST{}) + + var stats *extension.ComplexityStats + h.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + stats = extension.GetComplexityStats(ctx) + return next(ctx) + }) + + t.Run("below complexity limit", func(t *testing.T) { + h.SetCalculatedComplexity(2) + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }"}`) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + + require.Equal(t, 2, stats.ComplexityLimit) + require.Equal(t, 2, stats.Complexity) + }) + + t.Run("above complexity limit", func(t *testing.T) { + h.SetCalculatedComplexity(4) + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }"}`) + require.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"operation has complexity 4, which exceeds the limit of 2"}],"data":null}`, resp.Body.String()) + + require.Equal(t, 2, stats.ComplexityLimit) + require.Equal(t, 4, stats.Complexity) + }) +} + +func doRequest(handler http.Handler, method string, target string, body string) *httptest.ResponseRecorder { + r := httptest.NewRequest(method, target, strings.NewReader(body)) + r.Header.Set("Content-Type", "application/json") + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w +} diff --git a/graphql/handler/extension/introspection.go b/graphql/handler/extension/introspection.go new file mode 100644 index 00000000000..6cfc8bace5a --- /dev/null +++ b/graphql/handler/extension/introspection.go @@ -0,0 +1,29 @@ +package extension + +import ( + "context" + + "github.com/99designs/gqlgen/graphql" + "github.com/vektah/gqlparser/gqlerror" +) + +// EnableIntrospection enables clients to reflect all of the types available on the graph. +type Introspection struct{} + +var _ interface { + graphql.OperationContextMutator + graphql.HandlerExtension +} = Introspection{} + +func (c Introspection) ExtensionName() string { + return "Introspection" +} + +func (c Introspection) Validate(schema graphql.ExecutableSchema) error { + return nil +} + +func (c Introspection) MutateOperationContext(ctx context.Context, rc *graphql.OperationContext) *gqlerror.Error { + rc.DisableIntrospection = false + return nil +} diff --git a/graphql/handler/extension/introspection_test.go b/graphql/handler/extension/introspection_test.go new file mode 100644 index 00000000000..e001eb529f0 --- /dev/null +++ b/graphql/handler/extension/introspection_test.go @@ -0,0 +1,17 @@ +package extension + +import ( + "context" + "testing" + + "github.com/99designs/gqlgen/graphql" + "github.com/stretchr/testify/require" +) + +func TestIntrospection(t *testing.T) { + rc := &graphql.OperationContext{ + DisableIntrospection: true, + } + require.Nil(t, Introspection{}.MutateOperationContext(context.Background(), rc)) + require.Equal(t, false, rc.DisableIntrospection) +} diff --git a/graphql/handler/lru/lru.go b/graphql/handler/lru/lru.go new file mode 100644 index 00000000000..e539fdf4fe8 --- /dev/null +++ b/graphql/handler/lru/lru.go @@ -0,0 +1,30 @@ +package lru + +import ( + "github.com/99designs/gqlgen/graphql" + lru "github.com/hashicorp/golang-lru" +) + +type LRU struct { + lru *lru.Cache +} + +var _ graphql.Cache = &LRU{} + +func New(size int) *LRU { + cache, err := lru.New(size) + if err != nil { + // An error is only returned for non-positive cache size + // and we already checked for that. + panic("unexpected error creating cache: " + err.Error()) + } + return &LRU{cache} +} + +func (l LRU) Get(key string) (value interface{}, ok bool) { + return l.lru.Get(key) +} + +func (l LRU) Add(key string, value interface{}) { + l.lru.Add(key, value) +} diff --git a/graphql/handler/server.go b/graphql/handler/server.go new file mode 100644 index 00000000000..042bd588a28 --- /dev/null +++ b/graphql/handler/server.go @@ -0,0 +1,205 @@ +package handler + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "time" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler/extension" + "github.com/99designs/gqlgen/graphql/handler/lru" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/vektah/gqlparser/gqlerror" +) + +type ( + Server struct { + es graphql.ExecutableSchema + transports []graphql.Transport + extensions []graphql.HandlerExtension + exec executor + + errorPresenter graphql.ErrorPresenterFunc + recoverFunc graphql.RecoverFunc + queryCache graphql.Cache + } +) + +func New(es graphql.ExecutableSchema) *Server { + s := &Server{ + es: es, + errorPresenter: graphql.DefaultErrorPresenter, + recoverFunc: graphql.DefaultRecover, + queryCache: graphql.NoCache{}, + } + s.exec = newExecutor(s) + return s +} + +func NewDefaultServer(es graphql.ExecutableSchema) *Server { + srv := New(es) + + srv.AddTransport(transport.Websocket{ + KeepAlivePingInterval: 10 * time.Second, + }) + srv.AddTransport(transport.Options{}) + srv.AddTransport(transport.GET{}) + srv.AddTransport(transport.POST{}) + srv.AddTransport(transport.MultipartForm{}) + + srv.SetQueryCache(lru.New(1000)) + + srv.Use(extension.Introspection{}) + srv.Use(extension.AutomaticPersistedQuery{ + Cache: lru.New(100), + }) + + return srv +} + +func (s *Server) AddTransport(transport graphql.Transport) { + s.transports = append(s.transports, transport) +} + +func (s *Server) SetErrorPresenter(f graphql.ErrorPresenterFunc) { + s.errorPresenter = f +} + +func (s *Server) SetRecoverFunc(f graphql.RecoverFunc) { + s.recoverFunc = f +} + +func (s *Server) SetQueryCache(cache graphql.Cache) { + s.queryCache = cache +} + +func (s *Server) Use(extension graphql.HandlerExtension) { + if err := extension.Validate(s.es); err != nil { + panic(err) + } + + switch extension.(type) { + case graphql.OperationParameterMutator, + graphql.OperationContextMutator, + graphql.OperationInterceptor, + graphql.FieldInterceptor, + graphql.ResponseInterceptor: + s.extensions = append(s.extensions, extension) + s.exec = newExecutor(s) + + default: + panic(fmt.Errorf("cannot Use %T as a gqlgen handler extension because it does not implement any extension hooks", extension)) + } +} + +// AroundFields is a convenience method for creating an extension that only implements field middleware +func (s *Server) AroundFields(f graphql.FieldMiddleware) { + s.Use(FieldFunc(f)) +} + +// AroundOperations is a convenience method for creating an extension that only implements operation middleware +func (s *Server) AroundOperations(f graphql.OperationMiddleware) { + s.Use(OperationFunc(f)) +} + +// AroundResponses is a convenience method for creating an extension that only implements response middleware +func (s *Server) AroundResponses(f graphql.ResponseMiddleware) { + s.Use(ResponseFunc(f)) +} + +func (s *Server) getTransport(r *http.Request) graphql.Transport { + for _, t := range s.transports { + if t.Supports(r) { + return t + } + } + return nil +} + +func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { + defer func() { + if err := recover(); err != nil { + err := s.errorPresenter(r.Context(), s.recoverFunc(r.Context(), err)) + resp := &graphql.Response{Errors: []*gqlerror.Error{err}} + b, _ := json.Marshal(resp) + w.WriteHeader(http.StatusUnprocessableEntity) + w.Write(b) + } + }() + + r = r.WithContext(graphql.StartOperationTrace(r.Context())) + + transport := s.getTransport(r) + if transport == nil { + sendErrorf(w, http.StatusBadRequest, "transport not supported") + return + } + + transport.Do(w, r, s.exec) +} + +func sendError(w http.ResponseWriter, code int, errors ...*gqlerror.Error) { + w.WriteHeader(code) + b, err := json.Marshal(&graphql.Response{Errors: errors}) + if err != nil { + panic(err) + } + w.Write(b) +} + +func sendErrorf(w http.ResponseWriter, code int, format string, args ...interface{}) { + sendError(w, code, &gqlerror.Error{Message: fmt.Sprintf(format, args...)}) +} + +type OperationFunc func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler + +func (r OperationFunc) ExtensionName() string { + return "InlineOperationFunc" +} + +func (r OperationFunc) Validate(schema graphql.ExecutableSchema) error { + if r == nil { + return fmt.Errorf("OperationFunc can not be nil") + } + return nil +} + +func (r OperationFunc) InterceptOperation(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + return r(ctx, next) +} + +type ResponseFunc func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response + +func (r ResponseFunc) ExtensionName() string { + return "InlineResponseFunc" +} + +func (r ResponseFunc) Validate(schema graphql.ExecutableSchema) error { + if r == nil { + return fmt.Errorf("ResponseFunc can not be nil") + } + return nil +} + +func (r ResponseFunc) InterceptResponse(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + return r(ctx, next) +} + +type FieldFunc func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) + +func (f FieldFunc) ExtensionName() string { + return "InlineFieldFunc" +} + +func (f FieldFunc) Validate(schema graphql.ExecutableSchema) error { + if f == nil { + return fmt.Errorf("FieldFunc can not be nil") + } + return nil +} + +func (f FieldFunc) InterceptField(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + return f(ctx, next) +} diff --git a/graphql/handler/server_test.go b/graphql/handler/server_test.go new file mode 100644 index 00000000000..e141c19e734 --- /dev/null +++ b/graphql/handler/server_test.go @@ -0,0 +1,142 @@ +package handler_test + +import ( + "context" + "net/http" + "net/http/httptest" + "net/url" + "testing" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler/testserver" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/ast" + "github.com/vektah/gqlparser/parser" +) + +func TestServer(t *testing.T) { + srv := testserver.New() + srv.AddTransport(&transport.GET{}) + + t.Run("returns an error if no transport matches", func(t *testing.T) { + resp := post(srv, "/foo", "application/json") + assert.Equal(t, http.StatusBadRequest, resp.Code) + assert.Equal(t, `{"errors":[{"message":"transport not supported"}],"data":null}`, resp.Body.String()) + }) + + t.Run("calls query on executable schema", func(t *testing.T) { + resp := get(srv, "/foo?query={name}") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + + t.Run("mutations are forbidden", func(t *testing.T) { + resp := get(srv, "/foo?query=mutation{name}") + assert.Equal(t, http.StatusNotAcceptable, resp.Code) + assert.Equal(t, `{"errors":[{"message":"GET requests only allow query operations"}],"data":null}`, resp.Body.String()) + }) + + t.Run("subscriptions are forbidden", func(t *testing.T) { + resp := get(srv, "/foo?query=subscription{name}") + assert.Equal(t, http.StatusNotAcceptable, resp.Code) + assert.Equal(t, `{"errors":[{"message":"GET requests only allow query operations"}],"data":null}`, resp.Body.String()) + }) + + t.Run("invokes operation middleware in order", func(t *testing.T) { + var calls []string + srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + calls = append(calls, "first") + return next(ctx) + }) + srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + calls = append(calls, "second") + return next(ctx) + }) + + resp := get(srv, "/foo?query={name}") + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, []string{"first", "second"}, calls) + }) + + t.Run("invokes response middleware in order", func(t *testing.T) { + var calls []string + srv.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + calls = append(calls, "first") + return next(ctx) + }) + srv.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + calls = append(calls, "second") + return next(ctx) + }) + + resp := get(srv, "/foo?query={name}") + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, []string{"first", "second"}, calls) + }) + + t.Run("invokes field middleware in order", func(t *testing.T) { + var calls []string + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + calls = append(calls, "first") + return next(ctx) + }) + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + calls = append(calls, "second") + return next(ctx) + }) + + resp := get(srv, "/foo?query={name}") + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, []string{"first", "second"}, calls) + }) + + t.Run("query caching", func(t *testing.T) { + cache := &graphql.MapCache{} + srv.SetQueryCache(cache) + qry := `query Foo {name}` + + t.Run("cache miss populates cache", func(t *testing.T) { + resp := get(srv, "/foo?query="+url.QueryEscape(qry)) + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + + cacheDoc, ok := cache.Get(qry) + require.True(t, ok) + require.Equal(t, "Foo", cacheDoc.(*ast.QueryDocument).Operations[0].Name) + }) + + t.Run("cache hits use document from cache", func(t *testing.T) { + doc, err := parser.ParseQuery(&ast.Source{Input: `query Bar {name}`}) + require.Nil(t, err) + cache.Add(qry, doc) + + resp := get(srv, "/foo?query="+url.QueryEscape(qry)) + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + + cacheDoc, ok := cache.Get(qry) + require.True(t, ok) + require.Equal(t, "Bar", cacheDoc.(*ast.QueryDocument).Operations[0].Name) + }) + }) + +} + +func get(handler http.Handler, target string) *httptest.ResponseRecorder { + r := httptest.NewRequest("GET", target, nil) + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w +} + +func post(handler http.Handler, target, contentType string) *httptest.ResponseRecorder { + r := httptest.NewRequest("POST", target, nil) + r.Header.Set("Content-Type", contentType) + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w +} diff --git a/graphql/handler/testserver/testserver.go b/graphql/handler/testserver/testserver.go new file mode 100644 index 00000000000..0a1d91b420a --- /dev/null +++ b/graphql/handler/testserver/testserver.go @@ -0,0 +1,118 @@ +package testserver + +import ( + "context" + "fmt" + "time" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/vektah/gqlparser" + "github.com/vektah/gqlparser/ast" +) + +// New provides a server for use in tests that isn't relying on generated code. It isnt a perfect reproduction of +// a generated server, but it aims to be good enough to test the handler package without relying on codegen. +func New() *TestServer { + next := make(chan struct{}) + now := time.Unix(0, 0) + + graphql.Now = func() time.Time { + defer func() { + now = now.Add(100 * time.Nanosecond) + }() + return now + } + + schema := gqlparser.MustLoadSchema(&ast.Source{Input: ` + type Query { + name: String! + find(id: Int!): String! + } + type Mutation { + name: String! + } + type Subscription { + name: String! + } + `}) + + srv := &TestServer{ + next: next, + } + + srv.Server = handler.New(&graphql.ExecutableSchemaMock{ + ExecFunc: func(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + switch rc.Operation.Operation { + case ast.Query: + ran := false + return func(ctx context.Context) *graphql.Response { + if ran { + return nil + } + ran = true + // Field execution happens inside the generated code, lets simulate some of it. + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ + Object: "Query", + Field: graphql.CollectedField{ + Field: &ast.Field{ + Name: "name", + Alias: "name", + Definition: schema.Types["Query"].Fields.ForName("name"), + }, + }, + }) + res, err := graphql.GetOperationContext(ctx).ResolverMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return &graphql.Response{Data: []byte(`{"name":"test"}`)}, nil + }) + if err != nil { + panic(err) + } + return res.(*graphql.Response) + } + case ast.Mutation: + return graphql.OneShot(graphql.ErrorResponse(ctx, "mutations are not supported")) + case ast.Subscription: + return func(context context.Context) *graphql.Response { + select { + case <-ctx.Done(): + return nil + case <-next: + return &graphql.Response{ + Data: []byte(`{"name":"test"}`), + } + } + } + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } + }, + SchemaFunc: func() *ast.Schema { + return schema + }, + ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (i int, b bool) { + return srv.complexity, true + }, + }) + return srv +} + +type TestServer struct { + *handler.Server + next chan struct{} + complexity int +} + +func (s *TestServer) SendNextSubscriptionMessage() { + select { + case s.next <- struct{}{}: + case <-time.After(1 * time.Second): + fmt.Println("WARNING: no active subscription") + } + +} + +func (s *TestServer) SetCalculatedComplexity(complexity int) { + s.complexity = complexity +} diff --git a/graphql/handler/transport/error.go b/graphql/handler/transport/error.go new file mode 100644 index 00000000000..e03481c9c0d --- /dev/null +++ b/graphql/handler/transport/error.go @@ -0,0 +1,26 @@ +package transport + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/99designs/gqlgen/graphql" + "github.com/vektah/gqlparser/gqlerror" +) + +// SendError sends a best effort error to a raw response writer. It assumes the client can understand the standard +// json error response +func SendError(w http.ResponseWriter, code int, errors ...*gqlerror.Error) { + w.WriteHeader(code) + b, err := json.Marshal(&graphql.Response{Errors: errors}) + if err != nil { + panic(err) + } + w.Write(b) +} + +// SendErrorf wraps SendError to add formatted messages +func SendErrorf(w http.ResponseWriter, code int, format string, args ...interface{}) { + SendError(w, code, &gqlerror.Error{Message: fmt.Sprintf(format, args...)}) +} diff --git a/graphql/handler/transport/http_form.go b/graphql/handler/transport/http_form.go new file mode 100644 index 00000000000..3418993a043 --- /dev/null +++ b/graphql/handler/transport/http_form.go @@ -0,0 +1,198 @@ +package transport + +import ( + "encoding/json" + "io" + "io/ioutil" + "mime" + "net/http" + "os" + "strings" + + "github.com/99designs/gqlgen/graphql" +) + +// MultipartForm the Multipart request spec https://github.com/jaydenseric/graphql-multipart-request-spec +type MultipartForm struct { + // MaxUploadSize sets the maximum number of bytes used to parse a request body + // as multipart/form-data. + MaxUploadSize int64 + + // MaxMemory defines the maximum number of bytes used to parse a request body + // as multipart/form-data in memory, with the remainder stored on disk in + // temporary files. + MaxMemory int64 +} + +var _ graphql.Transport = MultipartForm{} + +func (f MultipartForm) Supports(r *http.Request) bool { + if r.Header.Get("Upgrade") != "" { + return false + } + + mediaType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return false + } + + return r.Method == "POST" && mediaType == "multipart/form-data" +} + +func (f MultipartForm) maxUploadSize() int64 { + if f.MaxUploadSize == 0 { + return 32 << 20 + } + return f.MaxUploadSize +} + +func (f MultipartForm) maxMemory() int64 { + if f.MaxMemory == 0 { + return 32 << 20 + } + return f.MaxMemory +} + +func (f MultipartForm) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { + w.Header().Set("Content-Type", "application/json") + + var err error + if r.ContentLength > f.maxUploadSize() { + writeJsonError(w, "failed to parse multipart form, request body too large") + return + } + r.Body = http.MaxBytesReader(w, r.Body, f.maxUploadSize()) + if err = r.ParseMultipartForm(f.maxUploadSize()); err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + if strings.Contains(err.Error(), "request body too large") { + writeJsonError(w, "failed to parse multipart form, request body too large") + return + } + writeJsonError(w, "failed to parse multipart form") + return + } + defer r.Body.Close() + + var params graphql.RawParams + + if err = jsonDecode(strings.NewReader(r.Form.Get("operations")), ¶ms); err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonError(w, "operations form field could not be decoded") + return + } + + var uploadsMap = map[string][]string{} + if err = json.Unmarshal([]byte(r.Form.Get("map")), &uploadsMap); err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonError(w, "map form field could not be decoded") + return + } + + var upload graphql.Upload + for key, paths := range uploadsMap { + if len(paths) == 0 { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonErrorf(w, "invalid empty operations paths list for key %s", key) + return + } + file, header, err := r.FormFile(key) + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonErrorf(w, "failed to get key %s from form", key) + return + } + defer file.Close() + + if len(paths) == 1 { + upload = graphql.Upload{ + File: file, + Size: header.Size, + Filename: header.Filename, + } + + if err := params.AddUpload(upload, key, paths[0]); err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonGraphqlError(w, err) + return + } + } else { + if r.ContentLength < f.maxMemory() { + fileBytes, err := ioutil.ReadAll(file) + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonErrorf(w, "failed to read file for key %s", key) + return + } + for _, path := range paths { + upload = graphql.Upload{ + File: &bytesReader{s: &fileBytes, i: 0, prevRune: -1}, + Size: header.Size, + Filename: header.Filename, + } + + if err := params.AddUpload(upload, key, path); err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonGraphqlError(w, err) + return + } + } + } else { + tmpFile, err := ioutil.TempFile(os.TempDir(), "gqlgen-") + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonErrorf(w, "failed to create temp file for key %s", key) + return + } + tmpName := tmpFile.Name() + defer func() { + _ = os.Remove(tmpName) + }() + _, err = io.Copy(tmpFile, file) + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + if err := tmpFile.Close(); err != nil { + writeJsonErrorf(w, "failed to copy to temp file and close temp file for key %s", key) + return + } + writeJsonErrorf(w, "failed to copy to temp file for key %s", key) + return + } + if err := tmpFile.Close(); err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonErrorf(w, "failed to close temp file for key %s", key) + return + } + for _, path := range paths { + pathTmpFile, err := os.Open(tmpName) + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonErrorf(w, "failed to open temp file for key %s", key) + return + } + defer pathTmpFile.Close() + upload = graphql.Upload{ + File: pathTmpFile, + Size: header.Size, + Filename: header.Filename, + } + + if err := params.AddUpload(upload, key, path); err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonGraphqlError(w, err) + return + } + } + } + } + } + + rc, gerr := exec.CreateOperationContext(r.Context(), ¶ms) + if gerr != nil { + resp := exec.DispatchError(graphql.WithOperationContext(r.Context(), rc), gerr) + w.WriteHeader(http.StatusUnprocessableEntity) + writeJson(w, resp) + return + } + responses, ctx := exec.DispatchOperation(r.Context(), rc) + writeJson(w, responses(ctx)) +} diff --git a/graphql/handler/transport/http_form_test.go b/graphql/handler/transport/http_form_test.go new file mode 100644 index 00000000000..b41e216e559 --- /dev/null +++ b/graphql/handler/transport/http_form_test.go @@ -0,0 +1,292 @@ +package transport_test + +import ( + "bytes" + "context" + "io/ioutil" + "mime/multipart" + "net/http" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser" + "github.com/vektah/gqlparser/ast" +) + +func TestFileUpload(t *testing.T) { + es := &graphql.ExecutableSchemaMock{ + ExecFunc: func(ctx context.Context) graphql.ResponseHandler { + return graphql.OneShot(graphql.ErrorResponse(ctx, "not implemented")) + }, + SchemaFunc: func() *ast.Schema { + return gqlparser.MustLoadSchema(&ast.Source{Input: ` + type Mutation { + singleUpload(file: Upload!): String! + singleUploadWithPayload(req: UploadFile!): String! + multipleUpload(files: [Upload!]!): String! + multipleUploadWithPayload(req: [UploadFile!]!): String! + } + scalar Upload + scalar UploadFile + `}) + }, + } + + h := handler.New(es) + multipartForm := transport.MultipartForm{} + h.AddTransport(&multipartForm) + + t.Run("valid single file upload", func(t *testing.T) { + es.ExecFunc = func(ctx context.Context) graphql.ResponseHandler { + op := graphql.GetOperationContext(ctx).Operation + require.Equal(t, len(op.VariableDefinitions), 1) + require.Equal(t, op.VariableDefinitions[0].Variable, "file") + return graphql.OneShot(&graphql.Response{Data: []byte(`{"singleUpload":"test"}`)}) + } + + operations := `{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) }", "variables": { "file": null } }` + mapData := `{ "0": ["variables.file"] }` + files := []file{ + { + mapKey: "0", + name: "a.txt", + content: "test1", + }, + } + req := createUploadRequest(t, operations, mapData, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"singleUpload":"test"}}`, resp.Body.String()) + }) + + t.Run("valid single file upload with payload", func(t *testing.T) { + es.ExecFunc = func(ctx context.Context) graphql.ResponseHandler { + op := graphql.GetOperationContext(ctx).Operation + require.Equal(t, len(op.VariableDefinitions), 1) + require.Equal(t, op.VariableDefinitions[0].Variable, "req") + return graphql.OneShot(&graphql.Response{Data: []byte(`{"singleUploadWithPayload":"test"}`)}) + } + + operations := `{ "query": "mutation ($req: UploadFile!) { singleUploadWithPayload(req: $req) }", "variables": { "req": {"file": null, "id": 1 } } }` + mapData := `{ "0": ["variables.req.file"] }` + files := []file{ + { + mapKey: "0", + name: "a.txt", + content: "test1", + }, + } + req := createUploadRequest(t, operations, mapData, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"singleUploadWithPayload":"test"}}`, resp.Body.String()) + }) + + t.Run("valid file list upload", func(t *testing.T) { + es.ExecFunc = func(ctx context.Context) graphql.ResponseHandler { + op := graphql.GetOperationContext(ctx).Operation + require.Equal(t, len(op.VariableDefinitions), 1) + require.Equal(t, op.VariableDefinitions[0].Variable, "files") + return graphql.OneShot(&graphql.Response{Data: []byte(`{"multipleUpload":[{"id":1},{"id":2}]}`)}) + } + + operations := `{ "query": "mutation($files: [Upload!]!) { multipleUpload(files: $files) }", "variables": { "files": [null, null] } }` + mapData := `{ "0": ["variables.files.0"], "1": ["variables.files.1"] }` + files := []file{ + { + mapKey: "0", + name: "a.txt", + content: "test1", + }, + { + mapKey: "1", + name: "b.txt", + content: "test2", + }, + } + req := createUploadRequest(t, operations, mapData, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"multipleUpload":[{"id":1},{"id":2}]}}`, resp.Body.String()) + }) + + t.Run("valid file list upload with payload", func(t *testing.T) { + es.ExecFunc = func(ctx context.Context) graphql.ResponseHandler { + op := graphql.GetOperationContext(ctx).Operation + require.Equal(t, len(op.VariableDefinitions), 1) + require.Equal(t, op.VariableDefinitions[0].Variable, "req") + return graphql.OneShot(&graphql.Response{Data: []byte(`{"multipleUploadWithPayload":[{"id":1},{"id":2}]}`)}) + } + + operations := `{ "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } }` + mapData := `{ "0": ["variables.req.0.file"], "1": ["variables.req.1.file"] }` + files := []file{ + { + mapKey: "0", + name: "a.txt", + content: "test1", + }, + { + mapKey: "1", + name: "b.txt", + content: "test2", + }, + } + req := createUploadRequest(t, operations, mapData, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code) + require.Equal(t, `{"data":{"multipleUploadWithPayload":[{"id":1},{"id":2}]}}`, resp.Body.String()) + }) + + t.Run("valid file list upload with payload and file reuse", func(t *testing.T) { + test := func(uploadMaxMemory int64) { + es.ExecFunc = func(ctx context.Context) graphql.ResponseHandler { + op := graphql.GetOperationContext(ctx).Operation + require.Equal(t, len(op.VariableDefinitions), 1) + require.Equal(t, op.VariableDefinitions[0].Variable, "req") + return graphql.OneShot(&graphql.Response{Data: []byte(`{"multipleUploadWithPayload":[{"id":1},{"id":2}]}`)}) + } + multipartForm.MaxMemory = uploadMaxMemory + + operations := `{ "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } }` + mapData := `{ "0": ["variables.req.0.file", "variables.req.1.file"] }` + files := []file{ + { + mapKey: "0", + name: "a.txt", + content: "test1", + }, + } + req := createUploadRequest(t, operations, mapData, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"multipleUploadWithPayload":[{"id":1},{"id":2}]}}`, resp.Body.String()) + } + + t.Run("payload smaller than UploadMaxMemory, stored in memory", func(t *testing.T) { + test(5000) + }) + + t.Run("payload bigger than UploadMaxMemory, persisted to disk", func(t *testing.T) { + test(2) + }) + }) + + validOperations := `{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) }", "variables": { "file": null } }` + validMap := `{ "0": ["variables.file"] }` + validFiles := []file{ + { + mapKey: "0", + name: "a.txt", + content: "test1", + }, + } + + t.Run("failed to parse multipart", func(t *testing.T) { + req := &http.Request{ + Method: "POST", + Header: http.Header{"Content-Type": {`multipart/form-data; boundary="foo123"`}}, + Body: ioutil.NopCloser(new(bytes.Buffer)), + } + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"failed to parse multipart form"}],"data":null}`, resp.Body.String()) + }) + + t.Run("fail parse operation", func(t *testing.T) { + operations := `invalid operation` + req := createUploadRequest(t, operations, validMap, validFiles) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"operations form field could not be decoded"}],"data":null}`, resp.Body.String()) + }) + + t.Run("fail parse map", func(t *testing.T) { + mapData := `invalid map` + req := createUploadRequest(t, validOperations, mapData, validFiles) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"map form field could not be decoded"}],"data":null}`, resp.Body.String()) + }) + + t.Run("fail missing file", func(t *testing.T) { + var files []file + req := createUploadRequest(t, validOperations, validMap, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"failed to get key 0 from form"}],"data":null}`, resp.Body.String()) + }) + + t.Run("fail map entry with invalid operations paths prefix", func(t *testing.T) { + mapData := `{ "0": ["var.file"] }` + req := createUploadRequest(t, validOperations, mapData, validFiles) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"invalid operations paths for key 0"}],"data":null}`, resp.Body.String()) + }) + + t.Run("fail parse request big body", func(t *testing.T) { + multipartForm.MaxUploadSize = 2 + req := createUploadRequest(t, validOperations, validMap, validFiles) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"failed to parse multipart form, request body too large"}],"data":null}`, resp.Body.String()) + }) +} + +type file struct { + mapKey string + name string + content string +} + +func createUploadRequest(t *testing.T, operations, mapData string, files []file) *http.Request { + bodyBuf := &bytes.Buffer{} + bodyWriter := multipart.NewWriter(bodyBuf) + + err := bodyWriter.WriteField("operations", operations) + require.NoError(t, err) + + err = bodyWriter.WriteField("map", mapData) + require.NoError(t, err) + + for i := range files { + ff, err := bodyWriter.CreateFormFile(files[i].mapKey, files[i].name) + require.NoError(t, err) + _, err = ff.Write([]byte(files[i].content)) + require.NoError(t, err) + } + err = bodyWriter.Close() + require.NoError(t, err) + + req, err := http.NewRequest("POST", "/graphql", bodyBuf) + require.NoError(t, err) + + req.Header.Set("Content-Type", bodyWriter.FormDataContentType()) + return req +} diff --git a/graphql/handler/transport/http_get.go b/graphql/handler/transport/http_get.go new file mode 100644 index 00000000000..d263c22158b --- /dev/null +++ b/graphql/handler/transport/http_get.go @@ -0,0 +1,71 @@ +package transport + +import ( + "encoding/json" + "io" + "net/http" + "strings" + + "github.com/99designs/gqlgen/graphql" + "github.com/vektah/gqlparser/ast" +) + +// GET implements the GET side of the default HTTP transport +// defined in https://github.com/APIs-guru/graphql-over-http#get +type GET struct{} + +var _ graphql.Transport = GET{} + +func (h GET) Supports(r *http.Request) bool { + if r.Header.Get("Upgrade") != "" { + return false + } + + return r.Method == "GET" +} + +func (h GET) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { + raw := &graphql.RawParams{ + Query: r.URL.Query().Get("query"), + OperationName: r.URL.Query().Get("operationName"), + } + + if variables := r.URL.Query().Get("variables"); variables != "" { + if err := jsonDecode(strings.NewReader(variables), &raw.Variables); err != nil { + w.WriteHeader(http.StatusBadRequest) + writeJsonError(w, "variables could not be decoded") + return + } + } + + if extensions := r.URL.Query().Get("extensions"); extensions != "" { + if err := jsonDecode(strings.NewReader(extensions), &raw.Extensions); err != nil { + w.WriteHeader(http.StatusBadRequest) + writeJsonError(w, "extensions could not be decoded") + return + } + } + + rc, err := exec.CreateOperationContext(r.Context(), raw) + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + resp := exec.DispatchError(graphql.WithOperationContext(r.Context(), rc), err) + writeJson(w, resp) + return + } + op := rc.Doc.Operations.ForName(rc.OperationName) + if op.Operation != ast.Query { + w.WriteHeader(http.StatusNotAcceptable) + writeJsonError(w, "GET requests only allow query operations") + return + } + + responses, ctx := exec.DispatchOperation(r.Context(), rc) + writeJson(w, responses(ctx)) +} + +func jsonDecode(r io.Reader, val interface{}) error { + dec := json.NewDecoder(r) + dec.UseNumber() + return dec.Decode(val) +} diff --git a/graphql/handler/transport/http_get_test.go b/graphql/handler/transport/http_get_test.go new file mode 100644 index 00000000000..e0c09625230 --- /dev/null +++ b/graphql/handler/transport/http_get_test.go @@ -0,0 +1,45 @@ +package transport_test + +import ( + "net/http" + "testing" + + "github.com/99designs/gqlgen/graphql/handler/testserver" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/stretchr/testify/assert" +) + +func TestGET(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.GET{}) + + t.Run("success", func(t *testing.T) { + resp := doRequest(h, "GET", "/graphql?query={name}", ``) + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + + t.Run("decode failure", func(t *testing.T) { + resp := doRequest(h, "GET", "/graphql?query={name}&variables=notjson", "") + assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String()) + assert.Equal(t, `{"errors":[{"message":"variables could not be decoded"}],"data":null}`, resp.Body.String()) + }) + + t.Run("invalid variable", func(t *testing.T) { + resp := doRequest(h, "GET", `/graphql?query=query($id:Int!){find(id:$id)}&variables={"id":false}`, "") + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, `{"errors":[{"message":"cannot use bool as Int","path":["variable","id"]}],"data":null}`, resp.Body.String()) + }) + + t.Run("parse failure", func(t *testing.T) { + resp := doRequest(h, "GET", "/graphql?query=!", "") + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, `{"errors":[{"message":"Unexpected !","locations":[{"line":1,"column":1}]}],"data":null}`, resp.Body.String()) + }) + + t.Run("no mutations", func(t *testing.T) { + resp := doRequest(h, "GET", "/graphql?query=mutation{name}", "") + assert.Equal(t, http.StatusNotAcceptable, resp.Code, resp.Body.String()) + assert.Equal(t, `{"errors":[{"message":"GET requests only allow query operations"}],"data":null}`, resp.Body.String()) + }) +} diff --git a/graphql/handler/transport/http_post.go b/graphql/handler/transport/http_post.go new file mode 100644 index 00000000000..e024d97bd42 --- /dev/null +++ b/graphql/handler/transport/http_post.go @@ -0,0 +1,48 @@ +package transport + +import ( + "mime" + "net/http" + + "github.com/99designs/gqlgen/graphql" +) + +// POST implements the POST side of the default HTTP transport +// defined in https://github.com/APIs-guru/graphql-over-http#post +type POST struct{} + +var _ graphql.Transport = POST{} + +func (h POST) Supports(r *http.Request) bool { + if r.Header.Get("Upgrade") != "" { + return false + } + + mediaType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return false + } + + return r.Method == "POST" && mediaType == "application/json" +} + +func (h POST) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { + w.Header().Set("Content-Type", "application/json") + + var params *graphql.RawParams + if err := jsonDecode(r.Body, ¶ms); err != nil { + w.WriteHeader(http.StatusBadRequest) + writeJsonErrorf(w, "json body could not be decoded: "+err.Error()) + return + } + + rc, err := exec.CreateOperationContext(r.Context(), params) + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + resp := exec.DispatchError(graphql.WithOperationContext(r.Context(), rc), err) + writeJson(w, resp) + return + } + responses, ctx := exec.DispatchOperation(r.Context(), rc) + writeJson(w, responses(ctx)) +} diff --git a/graphql/handler/transport/http_post_test.go b/graphql/handler/transport/http_post_test.go new file mode 100644 index 00000000000..8e389b023be --- /dev/null +++ b/graphql/handler/transport/http_post_test.go @@ -0,0 +1,111 @@ +package transport_test + +import ( + "fmt" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/99designs/gqlgen/graphql/handler/testserver" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/stretchr/testify/assert" +) + +func TestPOST(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.POST{}) + + t.Run("success", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }"}`) + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + + t.Run("decode failure", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", "notjson") + assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"json body could not be decoded: invalid character 'o' in literal null (expecting 'u')"}],"data":null}`, resp.Body.String()) + }) + + t.Run("parse failure", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query": "!"}`) + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"Unexpected !","locations":[{"line":1,"column":1}]}],"data":null}`, resp.Body.String()) + }) + + t.Run("validation failure", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query": "{ title }"}`) + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"Cannot query field \"title\" on type \"Query\".","locations":[{"line":1,"column":3}]}],"data":null}`, resp.Body.String()) + }) + + t.Run("invalid variable", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query": "query($id:Int!){find(id:$id)}","variables":{"id":false}}`) + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"cannot use bool as Int","path":["variable","id"]}],"data":null}`, resp.Body.String()) + }) + + t.Run("execution failure", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query": "mutation { name }"}`) + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"mutations are not supported"}],"data":null}`, resp.Body.String()) + }) + + t.Run("validate content type", func(t *testing.T) { + doReq := func(handler http.Handler, method string, target string, body string, contentType string) *httptest.ResponseRecorder { + r := httptest.NewRequest(method, target, strings.NewReader(body)) + if contentType != "" { + r.Header.Set("Content-Type", contentType) + } + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w + } + + validContentTypes := []string{ + "application/json", + "application/json; charset=utf-8", + } + + for _, contentType := range validContentTypes { + t.Run(fmt.Sprintf("allow for content type %s", contentType), func(t *testing.T) { + resp := doReq(h, "POST", "/graphql", `{"query":"{ name }"}`, contentType) + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + } + + invalidContentTypes := []string{ + "", + "text/plain", + + // These content types are currently not supported, but they are supported by other GraphQL servers, like express-graphql. + "application/x-www-form-urlencoded", + "application/graphql", + } + + for _, tc := range invalidContentTypes { + t.Run(fmt.Sprintf("reject for content type %s", tc), func(t *testing.T) { + resp := doReq(h, "POST", "/graphql", `{"query":"{ name }"}`, tc) + assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String()) + assert.Equal(t, fmt.Sprintf(`{"errors":[{"message":"%s"}],"data":null}`, "transport not supported"), resp.Body.String()) + }) + } + }) +} + +func doRequest(handler http.Handler, method string, target string, body string) *httptest.ResponseRecorder { + r := httptest.NewRequest(method, target, strings.NewReader(body)) + r.Header.Set("Content-Type", "application/json") + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w +} diff --git a/graphql/handler/transport/options.go b/graphql/handler/transport/options.go new file mode 100644 index 00000000000..674a00c7f09 --- /dev/null +++ b/graphql/handler/transport/options.go @@ -0,0 +1,26 @@ +package transport + +import ( + "net/http" + + "github.com/99designs/gqlgen/graphql" +) + +// Options responds to http OPTIONS and HEAD requests +type Options struct{} + +var _ graphql.Transport = Options{} + +func (o Options) Supports(r *http.Request) bool { + return r.Method == "HEAD" || r.Method == "OPTIONS" +} + +func (o Options) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { + switch r.Method { + case http.MethodOptions: + w.WriteHeader(http.StatusOK) + w.Header().Set("Allow", "OPTIONS, GET, POST") + case http.MethodHead: + w.WriteHeader(http.StatusMethodNotAllowed) + } +} diff --git a/graphql/handler/transport/options_test.go b/graphql/handler/transport/options_test.go new file mode 100644 index 00000000000..516595f33dd --- /dev/null +++ b/graphql/handler/transport/options_test.go @@ -0,0 +1,26 @@ +package transport_test + +import ( + "net/http" + "testing" + + "github.com/99designs/gqlgen/graphql/handler/testserver" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/stretchr/testify/assert" +) + +func TestOptions(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Options{}) + + t.Run("responds to options requests", func(t *testing.T) { + resp := doRequest(h, "OPTIONS", "/graphql?query={me{name}}", ``) + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, "OPTIONS, GET, POST", resp.Header().Get("Allow")) + }) + + t.Run("responds to head requests", func(t *testing.T) { + resp := doRequest(h, "HEAD", "/graphql?query={me{name}}", ``) + assert.Equal(t, http.StatusMethodNotAllowed, resp.Code) + }) +} diff --git a/graphql/handler/transport/reader.go b/graphql/handler/transport/reader.go new file mode 100644 index 00000000000..d3261e28335 --- /dev/null +++ b/graphql/handler/transport/reader.go @@ -0,0 +1,25 @@ +package transport + +import ( + "errors" + "io" +) + +type bytesReader struct { + s *[]byte + i int64 // current reading index + prevRune int // index of previous rune; or < 0 +} + +func (r *bytesReader) Read(b []byte) (n int, err error) { + if r.s == nil { + return 0, errors.New("byte slice pointer is nil") + } + if r.i >= int64(len(*r.s)) { + return 0, io.EOF + } + r.prevRune = -1 + n = copy(b, (*r.s)[r.i:]) + r.i += int64(n) + return +} diff --git a/graphql/handler/transport/reader_test.go b/graphql/handler/transport/reader_test.go new file mode 100644 index 00000000000..eaff3b2b817 --- /dev/null +++ b/graphql/handler/transport/reader_test.go @@ -0,0 +1,85 @@ +package transport + +import ( + "io" + "sync" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestBytesRead(t *testing.T) { + t.Run("test concurrency", func(t *testing.T) { + // Test for the race detector, to verify a Read that doesn't yield any bytes + // is okay to use from multiple goroutines. This was our historic behavior. + // See golang.org/issue/7856 + r := bytesReader{s: &([]byte{})} + var wg sync.WaitGroup + for i := 0; i < 5; i++ { + wg.Add(2) + go func() { + defer wg.Done() + var buf [1]byte + r.Read(buf[:]) + }() + go func() { + defer wg.Done() + r.Read(nil) + }() + } + wg.Wait() + }) + + t.Run("fail to read if pointer is nil", func(t *testing.T) { + n, err := (&bytesReader{}).Read(nil) + require.Equal(t, 0, n) + require.NotNil(t, err) + require.Equal(t, "byte slice pointer is nil", err.Error()) + }) + + t.Run("read using buffer", func(t *testing.T) { + data := []byte("0123456789") + r := bytesReader{s: &data} + + got := make([]byte, 0, 11) + buf := make([]byte, 1) + for { + n, err := r.Read(buf) + if n < 0 { + require.Fail(t, "unexpected bytes read size") + } + got = append(got, buf[:n]...) + if err != nil { + if err == io.EOF { + break + } + require.Fail(t, "unexpected error while reading", err.Error()) + } + } + require.Equal(t, "0123456789", string(got)) + }) + + t.Run("read updated pointer value", func(t *testing.T) { + data := []byte("0123456789") + pointer := &data + r := bytesReader{s: pointer} + data[2] = []byte("9")[0] + + got := make([]byte, 0, 11) + buf := make([]byte, 1) + for { + n, err := r.Read(buf) + if n < 0 { + require.Fail(t, "unexpected bytes read size") + } + got = append(got, buf[:n]...) + if err != nil { + if err == io.EOF { + break + } + require.Fail(t, "unexpected error while reading", err.Error()) + } + } + require.Equal(t, "0193456789", string(got)) + }) +} diff --git a/graphql/handler/transport/util.go b/graphql/handler/transport/util.go new file mode 100644 index 00000000000..d2de3664304 --- /dev/null +++ b/graphql/handler/transport/util.go @@ -0,0 +1,30 @@ +package transport + +import ( + "encoding/json" + "fmt" + "io" + + "github.com/99designs/gqlgen/graphql" + "github.com/vektah/gqlparser/gqlerror" +) + +func writeJson(w io.Writer, response *graphql.Response) { + b, err := json.Marshal(response) + if err != nil { + panic(err) + } + w.Write(b) +} + +func writeJsonError(w io.Writer, msg string) { + writeJson(w, &graphql.Response{Errors: gqlerror.List{{Message: msg}}}) +} + +func writeJsonErrorf(w io.Writer, format string, args ...interface{}) { + writeJson(w, &graphql.Response{Errors: gqlerror.List{{Message: fmt.Sprintf(format, args...)}}}) +} + +func writeJsonGraphqlError(w io.Writer, err ...*gqlerror.Error) { + writeJson(w, &graphql.Response{Errors: err}) +} diff --git a/handler/websocket.go b/graphql/handler/transport/websocket.go similarity index 62% rename from handler/websocket.go rename to graphql/handler/transport/websocket.go index 3d1cc36cfcb..bbbc2c1a241 100644 --- a/handler/websocket.go +++ b/graphql/handler/transport/websocket.go @@ -1,4 +1,4 @@ -package handler +package transport import ( "bytes" @@ -12,11 +12,7 @@ import ( "github.com/99designs/gqlgen/graphql" "github.com/gorilla/websocket" - lru "github.com/hashicorp/golang-lru" - "github.com/vektah/gqlparser" - "github.com/vektah/gqlparser/ast" "github.com/vektah/gqlparser/gqlerror" - "github.com/vektah/gqlparser/validator" ) const ( @@ -32,42 +28,53 @@ const ( connectionKeepAliveMsg = "ka" // Server -> Client ) -type operationMessage struct { - Payload json.RawMessage `json:"payload,omitempty"` - ID string `json:"id,omitempty"` - Type string `json:"type"` -} +type ( + Websocket struct { + Upgrader websocket.Upgrader + InitFunc WebsocketInitFunc + KeepAlivePingInterval time.Duration + } + wsConnection struct { + Websocket + ctx context.Context + conn *websocket.Conn + active map[string]context.CancelFunc + mu sync.Mutex + keepAliveTicker *time.Ticker + exec graphql.GraphExecutor + + initPayload InitPayload + } + operationMessage struct { + Payload json.RawMessage `json:"payload,omitempty"` + ID string `json:"id,omitempty"` + Type string `json:"type"` + } + WebsocketInitFunc func(ctx context.Context, initPayload InitPayload) (context.Context, error) +) -type wsConnection struct { - ctx context.Context - conn *websocket.Conn - exec graphql.ExecutableSchema - active map[string]context.CancelFunc - mu sync.Mutex - cfg *Config - cache *lru.Cache - keepAliveTicker *time.Ticker - - initPayload InitPayload +var _ graphql.Transport = Websocket{} + +func (t Websocket) Supports(r *http.Request) bool { + return r.Header.Get("Upgrade") != "" } -func connectWs(exec graphql.ExecutableSchema, w http.ResponseWriter, r *http.Request, cfg *Config, cache *lru.Cache) { - ws, err := cfg.upgrader.Upgrade(w, r, http.Header{ +func (t Websocket) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { + ws, err := t.Upgrader.Upgrade(w, r, http.Header{ "Sec-Websocket-Protocol": []string{"graphql-ws"}, }) if err != nil { log.Printf("unable to upgrade %T to websocket %s: ", w, err.Error()) - sendErrorf(w, http.StatusBadRequest, "unable to upgrade") + SendErrorf(w, http.StatusBadRequest, "unable to upgrade") return } conn := wsConnection{ - active: map[string]context.CancelFunc{}, - exec: exec, - conn: ws, - ctx: r.Context(), - cfg: cfg, - cache: cache, + active: map[string]context.CancelFunc{}, + conn: ws, + ctx: r.Context(), + exec: exec, + Websocket: t, } if !conn.init() { @@ -94,8 +101,8 @@ func (c *wsConnection) init() bool { } } - if c.cfg.websocketInitFunc != nil { - ctx, err := c.cfg.websocketInitFunc(c.ctx, c.initPayload) + if c.InitFunc != nil { + ctx, err := c.InitFunc(c.ctx, c.initPayload) if err != nil { c.sendConnectionError(err.Error()) c.close(websocket.CloseNormalClosure, "terminated") @@ -131,9 +138,9 @@ func (c *wsConnection) run() { defer cancel() // Create a timer that will fire every interval to keep the connection alive. - if c.cfg.connectionKeepAlivePingInterval != 0 { + if c.KeepAlivePingInterval != 0 { c.mu.Lock() - c.keepAliveTicker = time.NewTicker(c.cfg.connectionKeepAlivePingInterval) + c.keepAliveTicker = time.NewTicker(c.KeepAlivePingInterval) c.mu.Unlock() go c.keepAlive(ctx) @@ -184,86 +191,55 @@ func (c *wsConnection) keepAlive(ctx context.Context) { } func (c *wsConnection) subscribe(message *operationMessage) bool { - var reqParams params - if err := jsonDecode(bytes.NewReader(message.Payload), &reqParams); err != nil { + ctx := graphql.StartOperationTrace(c.ctx) + var params *graphql.RawParams + if err := jsonDecode(bytes.NewReader(message.Payload), ¶ms); err != nil { c.sendConnectionError("invalid json") return false } - var ( - doc *ast.QueryDocument - cacheHit bool - ) - if c.cache != nil { - val, ok := c.cache.Get(reqParams.Query) - if ok { - doc = val.(*ast.QueryDocument) - cacheHit = true - } - } - if !cacheHit { - var qErr gqlerror.List - doc, qErr = gqlparser.LoadQuery(c.exec.Schema(), reqParams.Query) - if qErr != nil { - c.sendError(message.ID, qErr...) - return true - } - if c.cache != nil { - c.cache.Add(reqParams.Query, doc) - } - } - - op := doc.Operations.ForName(reqParams.OperationName) - if op == nil { - c.sendError(message.ID, gqlerror.Errorf("operation %s not found", reqParams.OperationName)) - return true - } - - vars, err := validator.VariableValues(c.exec.Schema(), op, reqParams.Variables) + rc, err := c.exec.CreateOperationContext(ctx, params) if err != nil { - c.sendError(message.ID, err) - return true - } - reqCtx, err2 := c.cfg.newRequestContext(c.ctx, c.exec, doc, op, reqParams.OperationName, reqParams.Query, vars) - if err2 != nil { - c.sendError(message.ID, gqlerror.Errorf(err2.Error())) - return true + resp := c.exec.DispatchError(graphql.WithOperationContext(ctx, rc), err) + c.sendError(message.ID, resp.Errors...) + return false } - ctx := graphql.WithRequestContext(c.ctx, reqCtx) + + ctx = graphql.WithOperationContext(ctx, rc) if c.initPayload != nil { ctx = withInitPayload(ctx, c.initPayload) } - if op.Operation != ast.Subscription { - var result *graphql.Response - if op.Operation == ast.Query { - result = c.exec.Query(ctx, op) - } else { - result = c.exec.Mutation(ctx, op) - } - - c.sendData(message.ID, result) - c.write(&operationMessage{ID: message.ID, Type: completeMsg}) - return true - } - ctx, cancel := context.WithCancel(ctx) c.mu.Lock() c.active[message.ID] = cancel c.mu.Unlock() + go func() { defer func() { if r := recover(); r != nil { - userErr := reqCtx.Recover(ctx, r) + userErr := rc.Recover(ctx, r) c.sendError(message.ID, &gqlerror.Error{Message: userErr.Error()}) } }() - next := c.exec.Subscription(ctx, op) - for result := next(); result != nil; result = next() { - c.sendData(message.ID, result) - } + responses, ctx := c.exec.DispatchOperation(ctx, rc) + for { + response := responses(ctx) + if response == nil { + break + } + b, err := json.Marshal(response) + if err != nil { + panic(err) + } + c.write(&operationMessage{ + Payload: b, + ID: message.ID, + Type: dataMsg, + }) + } c.write(&operationMessage{ID: message.ID, Type: completeMsg}) c.mu.Lock() @@ -275,16 +251,6 @@ func (c *wsConnection) subscribe(message *operationMessage) bool { return true } -func (c *wsConnection) sendData(id string, response *graphql.Response) { - b, err := json.Marshal(response) - if err != nil { - c.sendError(id, gqlerror.Errorf("unable to encode json response: %s", err.Error())) - return - } - - c.write(&operationMessage{Type: dataMsg, ID: id, Payload: b}) -} - func (c *wsConnection) sendError(id string, errors ...*gqlerror.Error) { errs := make([]error, len(errors)) for i, err := range errors { diff --git a/handler/context.go b/graphql/handler/transport/websocket_init.go similarity index 78% rename from handler/context.go rename to graphql/handler/transport/websocket_init.go index 2992aa3d4fe..a5f84ba2dc6 100644 --- a/handler/context.go +++ b/graphql/handler/transport/websocket_init.go @@ -1,4 +1,4 @@ -package handler +package transport import "context" @@ -14,12 +14,12 @@ type InitPayload map[string]interface{} // GetString safely gets a string value from the payload. It returns an empty string if the // payload is nil or the value isn't set. -func (payload InitPayload) GetString(key string) string { - if payload == nil { +func (p InitPayload) GetString(key string) string { + if p == nil { return "" } - if value, ok := payload[key]; ok { + if value, ok := p[key]; ok { res, _ := value.(string) return res } @@ -29,12 +29,12 @@ func (payload InitPayload) GetString(key string) string { // Authorization is a short hand for getting the Authorization header from the // payload. -func (payload InitPayload) Authorization() string { - if value := payload.GetString("Authorization"); value != "" { +func (p InitPayload) Authorization() string { + if value := p.GetString("Authorization"); value != "" { return value } - if value := payload.GetString("authorization"); value != "" { + if value := p.GetString("authorization"); value != "" { return value } diff --git a/graphql/handler/transport/websocket_test.go b/graphql/handler/transport/websocket_test.go new file mode 100644 index 00000000000..db91bebf51e --- /dev/null +++ b/graphql/handler/transport/websocket_test.go @@ -0,0 +1,311 @@ +package transport_test + +import ( + "context" + "encoding/json" + "errors" + "net/http/httptest" + "strings" + "testing" + "time" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/testserver" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/gorilla/websocket" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser" + "github.com/vektah/gqlparser/ast" +) + +func TestWebsocket(t *testing.T) { + handler := testserver.New() + handler.AddTransport(transport.Websocket{}) + + srv := httptest.NewServer(handler) + defer srv.Close() + + t.Run("client must send valid json", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + writeRaw(c, "hello") + + msg := readOp(c) + assert.Equal(t, "connection_error", msg.Type) + assert.Equal(t, `{"message":"invalid json"}`, string(msg.Payload)) + }) + + t.Run("client can terminate before init", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionTerminateMsg})) + + _, _, err := c.ReadMessage() + assert.Equal(t, websocket.CloseNormalClosure, err.(*websocket.CloseError).Code) + }) + + t.Run("client must send init first", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: startMsg})) + + msg := readOp(c) + assert.Equal(t, connectionErrorMsg, msg.Type) + assert.Equal(t, `{"message":"unexpected message start"}`, string(msg.Payload)) + }) + + t.Run("server acks init", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + }) + + t.Run("client can terminate before run", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionTerminateMsg})) + + _, _, err := c.ReadMessage() + assert.Equal(t, websocket.CloseNormalClosure, err.(*websocket.CloseError).Code) + }) + + t.Run("client gets parse errors", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + + require.NoError(t, c.WriteJSON(&operationMessage{ + Type: startMsg, + ID: "test_1", + Payload: json.RawMessage(`{"query": "!"}`), + })) + + msg := readOp(c) + assert.Equal(t, errorMsg, msg.Type) + assert.Equal(t, `[{"message":"Unexpected !","locations":[{"line":1,"column":1}]}]`, string(msg.Payload)) + }) + + t.Run("client can receive data", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + + require.NoError(t, c.WriteJSON(&operationMessage{ + Type: startMsg, + ID: "test_1", + Payload: json.RawMessage(`{"query": "subscription { name }"}`), + })) + + handler.SendNextSubscriptionMessage() + msg := readOp(c) + require.Equal(t, dataMsg, msg.Type, string(msg.Payload)) + require.Equal(t, "test_1", msg.ID, string(msg.Payload)) + require.Equal(t, `{"data":{"name":"test"}}`, string(msg.Payload)) + + handler.SendNextSubscriptionMessage() + msg = readOp(c) + require.Equal(t, dataMsg, msg.Type, string(msg.Payload)) + require.Equal(t, "test_1", msg.ID, string(msg.Payload)) + require.Equal(t, `{"data":{"name":"test"}}`, string(msg.Payload)) + + require.NoError(t, c.WriteJSON(&operationMessage{Type: stopMsg, ID: "test_1"})) + + msg = readOp(c) + require.Equal(t, completeMsg, msg.Type) + require.Equal(t, "test_1", msg.ID) + }) +} + +func TestWebsocketWithKeepAlive(t *testing.T) { + + h := testserver.New() + h.AddTransport(transport.Websocket{ + KeepAlivePingInterval: 10 * time.Millisecond, + }) + + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + + require.NoError(t, c.WriteJSON(&operationMessage{ + Type: startMsg, + ID: "test_1", + Payload: json.RawMessage(`{"query": "subscription { name }"}`), + })) + + // keepalive + msg := readOp(c) + assert.Equal(t, connectionKeepAliveMsg, msg.Type) + + // server message + h.SendNextSubscriptionMessage() + msg = readOp(c) + assert.Equal(t, dataMsg, msg.Type) + + // keepalive + msg = readOp(c) + assert.Equal(t, connectionKeepAliveMsg, msg.Type) +} + +func TestWebsocketInitFunc(t *testing.T) { + t.Run("accept connection if WebsocketInitFunc is NOT provided", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Websocket{}) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + }) + + t.Run("accept connection if WebsocketInitFunc is provided and is accepting connection", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Websocket{ + InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (context.Context, error) { + return context.WithValue(ctx, "newkey", "newvalue"), nil + }, + }) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + }) + + t.Run("reject connection if WebsocketInitFunc is provided and is accepting connection", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Websocket{ + InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (context.Context, error) { + return ctx, errors.New("invalid init payload") + }, + }) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + + msg := readOp(c) + assert.Equal(t, connectionErrorMsg, msg.Type) + assert.Equal(t, `{"message":"invalid init payload"}`, string(msg.Payload)) + }) + + t.Run("can return context for request from WebsocketInitFunc", func(t *testing.T) { + es := &graphql.ExecutableSchemaMock{ + ExecFunc: func(ctx context.Context) graphql.ResponseHandler { + assert.Equal(t, "newvalue", ctx.Value("newkey")) + return graphql.OneShot(&graphql.Response{Data: []byte(`{"empty":"ok"}`)}) + }, + SchemaFunc: func() *ast.Schema { + return gqlparser.MustLoadSchema(&ast.Source{Input: ` + schema { query: Query } + type Query { + empty: String + } + `}) + }, + } + h := handler.New(es) + + h.AddTransport(transport.Websocket{ + InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (context.Context, error) { + return context.WithValue(ctx, "newkey", "newvalue"), nil + }, + }) + + c := client.New(h) + + socket := c.Websocket("{ empty } ") + defer socket.Close() + var resp struct { + Empty string + } + err := socket.Next(&resp) + require.NoError(t, err) + assert.Equal(t, "ok", resp.Empty) + }) +} + +func wsConnect(url string) *websocket.Conn { + c, resp, err := websocket.DefaultDialer.Dial(strings.Replace(url, "http://", "ws://", -1), nil) + if err != nil { + panic(err) + } + _ = resp.Body.Close() + + return c +} + +func writeRaw(conn *websocket.Conn, msg string) { + if err := conn.WriteMessage(websocket.TextMessage, []byte(msg)); err != nil { + panic(err) + } +} + +func readOp(conn *websocket.Conn) operationMessage { + var msg operationMessage + if err := conn.ReadJSON(&msg); err != nil { + panic(err) + } + return msg +} + +// copied out from weboscket.go to keep these private + +const ( + connectionInitMsg = "connection_init" // Client -> Server + connectionTerminateMsg = "connection_terminate" // Client -> Server + startMsg = "start" // Client -> Server + stopMsg = "stop" // Client -> Server + connectionAckMsg = "connection_ack" // Server -> Client + connectionErrorMsg = "connection_error" // Server -> Client + dataMsg = "data" // Server -> Client + errorMsg = "error" // Server -> Client + completeMsg = "complete" // Server -> Client + connectionKeepAliveMsg = "ka" // Server -> Client +) + +type operationMessage struct { + Payload json.RawMessage `json:"payload,omitempty"` + ID string `json:"id,omitempty"` + Type string `json:"type"` +} diff --git a/graphql/handler_test.go b/graphql/handler_test.go new file mode 100644 index 00000000000..1caf965b9b7 --- /dev/null +++ b/graphql/handler_test.go @@ -0,0 +1,89 @@ +package graphql + +import ( + "os" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestAddUploadToOperations(t *testing.T) { + key := "0" + + t.Run("fail missing all variables", func(t *testing.T) { + file, _ := os.Open("path/to/file") + params := &RawParams{} + + upload := Upload{ + File: file, + Filename: "a.txt", + Size: int64(5), + } + path := "variables.req.0.file" + err := params.AddUpload(upload, key, path) + require.NotNil(t, err) + require.Equal(t, "input: path is missing \"variables.\" prefix, key: 0, path: variables.req.0.file", err.Error()) + }) + + t.Run("valid variable", func(t *testing.T) { + file, _ := os.Open("path/to/file") + request := &RawParams{ + Variables: map[string]interface{}{ + "file": nil, + }, + } + + upload := Upload{ + File: file, + Filename: "a.txt", + Size: int64(5), + } + + expected := &RawParams{ + Variables: map[string]interface{}{ + "file": upload, + }, + } + + path := "variables.file" + err := request.AddUpload(upload, key, path) + require.Nil(t, err) + + require.Equal(t, request, expected) + }) + + t.Run("valid nested variable", func(t *testing.T) { + file, _ := os.Open("path/to/file") + request := &RawParams{ + Variables: map[string]interface{}{ + "req": []interface{}{ + map[string]interface{}{ + "file": nil, + }, + }, + }, + } + + upload := Upload{ + File: file, + Filename: "a.txt", + Size: int64(5), + } + + expected := &RawParams{ + Variables: map[string]interface{}{ + "req": []interface{}{ + map[string]interface{}{ + "file": upload, + }, + }, + }, + } + + path := "variables.req.0.file" + err := request.AddUpload(upload, key, path) + require.Nil(t, err) + + require.Equal(t, request, expected) + }) +} diff --git a/graphql/oneshot.go b/graphql/oneshot.go index dd31f5baa79..01fa15f896b 100644 --- a/graphql/oneshot.go +++ b/graphql/oneshot.go @@ -1,9 +1,11 @@ package graphql -func OneShot(resp *Response) func() *Response { +import "context" + +func OneShot(resp *Response) ResponseHandler { var oneshot bool - return func() *Response { + return func(context context.Context) *Response { if oneshot { return nil } diff --git a/handler/playground.go b/graphql/playground/playground.go similarity index 96% rename from handler/playground.go rename to graphql/playground/playground.go index 2d5f3bcbef0..45bbbd4f143 100644 --- a/handler/playground.go +++ b/graphql/playground/playground.go @@ -1,4 +1,4 @@ -package handler +package playground import ( "html/template" @@ -44,7 +44,7 @@ var page = template.Must(template.New("graphiql").Parse(` `)) -func Playground(title string, endpoint string) http.HandlerFunc { +func Handler(title string, endpoint string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { w.Header().Add("Content-Type", "text/html") err := page.Execute(w, map[string]string{ diff --git a/graphql/recovery.go b/graphql/recovery.go index 3aa032dc5aa..d2cf9114287 100644 --- a/graphql/recovery.go +++ b/graphql/recovery.go @@ -6,6 +6,8 @@ import ( "fmt" "os" "runtime/debug" + + "github.com/vektah/gqlparser/gqlerror" ) type RecoverFunc func(ctx context.Context, err interface{}) (userMessage error) @@ -17,3 +19,21 @@ func DefaultRecover(ctx context.Context, err interface{}) error { return errors.New("internal system error") } + +var _ OperationContextMutator = RecoverFunc(nil) + +func (f RecoverFunc) ExtensionName() string { + return "RecoverFunc" +} + +func (f RecoverFunc) Validate(schema ExecutableSchema) error { + if f == nil { + return fmt.Errorf("RecoverFunc can not be nil") + } + return nil +} + +func (f RecoverFunc) MutateOperationContext(ctx context.Context, rc *OperationContext) *gqlerror.Error { + rc.Recover = f + return nil +} diff --git a/graphql/stats.go b/graphql/stats.go new file mode 100644 index 00000000000..f607f25a1e9 --- /dev/null +++ b/graphql/stats.go @@ -0,0 +1,59 @@ +package graphql + +import ( + "context" + "fmt" + "time" +) + +type Stats struct { + OperationStart time.Time + Parsing TraceTiming + Validation TraceTiming + + // Stats collected by handler extensions. Dont use directly, the extension should provide a type safe way to + // access this. + extension map[string]interface{} +} + +type TraceTiming struct { + Start time.Time + End time.Time +} + +var ctxTraceStart key = "trace_start" + +// StartOperationTrace captures the current time and stores it in context. This will eventually be added to request +// context but we want to grab it as soon as possible. For transports that can only handle a single graphql query +// per http requests you dont need to call this at all, the server will do it for you. For transports that handle +// multiple (eg batching, subscriptions) this should be called before decoding each request. +func StartOperationTrace(ctx context.Context) context.Context { + return context.WithValue(ctx, ctxTraceStart, Now()) +} + +// GetStartTime should only be called by the handler package, it will be set into request context +// as Stats.Start +func GetStartTime(ctx context.Context) time.Time { + t, ok := ctx.Value(ctxTraceStart).(time.Time) + if !ok { + panic(fmt.Sprintf("missing start time: %T", ctx.Value(ctxTraceStart))) + } + return t +} + +func (c *Stats) SetExtension(name string, data interface{}) { + if c.extension == nil { + c.extension = map[string]interface{}{} + } + c.extension[name] = data +} + +func (c *Stats) GetExtension(name string) interface{} { + if c.extension == nil { + return nil + } + return c.extension[name] +} + +// Now is time.Now, except in tests. Then it can be whatever you want it to be. +var Now = time.Now diff --git a/graphql/tracer.go b/graphql/tracer.go deleted file mode 100644 index 0597ce8cc8a..00000000000 --- a/graphql/tracer.go +++ /dev/null @@ -1,58 +0,0 @@ -package graphql - -import ( - "context" -) - -var _ Tracer = (*NopTracer)(nil) - -type Tracer interface { - StartOperationParsing(ctx context.Context) context.Context - EndOperationParsing(ctx context.Context) - StartOperationValidation(ctx context.Context) context.Context - EndOperationValidation(ctx context.Context) - StartOperationExecution(ctx context.Context) context.Context - StartFieldExecution(ctx context.Context, field CollectedField) context.Context - StartFieldResolverExecution(ctx context.Context, rc *ResolverContext) context.Context - StartFieldChildExecution(ctx context.Context) context.Context - EndFieldExecution(ctx context.Context) - EndOperationExecution(ctx context.Context) -} - -type NopTracer struct{} - -func (NopTracer) StartOperationParsing(ctx context.Context) context.Context { - return ctx -} - -func (NopTracer) EndOperationParsing(ctx context.Context) { -} - -func (NopTracer) StartOperationValidation(ctx context.Context) context.Context { - return ctx -} - -func (NopTracer) EndOperationValidation(ctx context.Context) { -} - -func (NopTracer) StartOperationExecution(ctx context.Context) context.Context { - return ctx -} - -func (NopTracer) StartFieldExecution(ctx context.Context, field CollectedField) context.Context { - return ctx -} - -func (NopTracer) StartFieldResolverExecution(ctx context.Context, rc *ResolverContext) context.Context { - return ctx -} - -func (NopTracer) StartFieldChildExecution(ctx context.Context) context.Context { - return ctx -} - -func (NopTracer) EndFieldExecution(ctx context.Context) { -} - -func (NopTracer) EndOperationExecution(ctx context.Context) { -} diff --git a/handler/graphql.go b/handler/graphql.go deleted file mode 100644 index 3d262518dde..00000000000 --- a/handler/graphql.go +++ /dev/null @@ -1,798 +0,0 @@ -package handler - -import ( - "context" - "crypto/sha256" - "encoding/hex" - "encoding/json" - "errors" - "fmt" - "io" - "io/ioutil" - "mime" - "net/http" - "os" - "strconv" - "strings" - "time" - - "github.com/99designs/gqlgen/complexity" - "github.com/99designs/gqlgen/graphql" - "github.com/gorilla/websocket" - lru "github.com/hashicorp/golang-lru" - "github.com/vektah/gqlparser/ast" - "github.com/vektah/gqlparser/gqlerror" - "github.com/vektah/gqlparser/parser" - "github.com/vektah/gqlparser/validator" -) - -type params struct { - Query string `json:"query"` - OperationName string `json:"operationName"` - Variables map[string]interface{} `json:"variables"` - Extensions *extensions `json:"extensions"` -} - -type extensions struct { - PersistedQuery *persistedQuery `json:"persistedQuery"` -} - -type persistedQuery struct { - Sha256 string `json:"sha256Hash"` - Version int64 `json:"version"` -} - -const ( - errPersistedQueryNotSupported = "PersistedQueryNotSupported" - errPersistedQueryNotFound = "PersistedQueryNotFound" -) - -type PersistedQueryCache interface { - Add(ctx context.Context, hash string, query string) - Get(ctx context.Context, hash string) (string, bool) -} - -type websocketInitFunc func(ctx context.Context, initPayload InitPayload) (context.Context, error) - -type Config struct { - cacheSize int - upgrader websocket.Upgrader - recover graphql.RecoverFunc - errorPresenter graphql.ErrorPresenterFunc - resolverHook graphql.FieldMiddleware - requestHook graphql.RequestMiddleware - tracer graphql.Tracer - complexityLimit int - complexityLimitFunc graphql.ComplexityLimitFunc - websocketInitFunc websocketInitFunc - disableIntrospection bool - connectionKeepAlivePingInterval time.Duration - uploadMaxMemory int64 - uploadMaxSize int64 - apqCache PersistedQueryCache -} - -func (c *Config) newRequestContext(ctx context.Context, es graphql.ExecutableSchema, doc *ast.QueryDocument, op *ast.OperationDefinition, operationName, query string, variables map[string]interface{}) (*graphql.RequestContext, error) { - reqCtx := &graphql.RequestContext{ - Doc: doc, - RawQuery: query, - Variables: variables, - OperationName: operationName, - DisableIntrospection: c.disableIntrospection, - Recover: c.recover, - ErrorPresenter: c.errorPresenter, - ResolverMiddleware: c.resolverHook, - RequestMiddleware: c.requestHook, - Tracer: c.tracer, - ComplexityLimit: c.complexityLimit, - } - if reqCtx.ComplexityLimit > 0 || c.complexityLimitFunc != nil { - reqCtx.OperationComplexity = complexity.Calculate(es, op, variables) - } - err := reqCtx.Validate(ctx) - if err != nil { - return nil, err - } - - return reqCtx, nil -} - -type Option func(cfg *Config) - -func WebsocketUpgrader(upgrader websocket.Upgrader) Option { - return func(cfg *Config) { - cfg.upgrader = upgrader - } -} - -func RecoverFunc(recover graphql.RecoverFunc) Option { - return func(cfg *Config) { - cfg.recover = recover - } -} - -// ErrorPresenter transforms errors found while resolving into errors that will be returned to the user. It provides -// a good place to add any extra fields, like error.type, that might be desired by your frontend. Check the default -// implementation in graphql.DefaultErrorPresenter for an example. -func ErrorPresenter(f graphql.ErrorPresenterFunc) Option { - return func(cfg *Config) { - cfg.errorPresenter = f - } -} - -// IntrospectionEnabled = false will forbid clients from calling introspection endpoints. Can be useful in prod when you dont -// want clients introspecting the full schema. -func IntrospectionEnabled(enabled bool) Option { - return func(cfg *Config) { - cfg.disableIntrospection = !enabled - } -} - -// ComplexityLimit sets a maximum query complexity that is allowed to be executed. -// If a query is submitted that exceeds the limit, a 422 status code will be returned. -func ComplexityLimit(limit int) Option { - return func(cfg *Config) { - cfg.complexityLimit = limit - } -} - -// ComplexityLimitFunc allows you to define a function to dynamically set the maximum query complexity that is allowed -// to be executed. -// If a query is submitted that exceeds the limit, a 422 status code will be returned. -func ComplexityLimitFunc(complexityLimitFunc graphql.ComplexityLimitFunc) Option { - return func(cfg *Config) { - cfg.complexityLimitFunc = complexityLimitFunc - } -} - -// ResolverMiddleware allows you to define a function that will be called around every resolver, -// useful for logging. -func ResolverMiddleware(middleware graphql.FieldMiddleware) Option { - return func(cfg *Config) { - if cfg.resolverHook == nil { - cfg.resolverHook = middleware - return - } - - lastResolve := cfg.resolverHook - cfg.resolverHook = func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - return lastResolve(ctx, func(ctx context.Context) (res interface{}, err error) { - return middleware(ctx, next) - }) - } - } -} - -// RequestMiddleware allows you to define a function that will be called around the root request, -// after the query has been parsed. This is useful for logging -func RequestMiddleware(middleware graphql.RequestMiddleware) Option { - return func(cfg *Config) { - if cfg.requestHook == nil { - cfg.requestHook = middleware - return - } - - lastResolve := cfg.requestHook - cfg.requestHook = func(ctx context.Context, next func(ctx context.Context) []byte) []byte { - return lastResolve(ctx, func(ctx context.Context) []byte { - return middleware(ctx, next) - }) - } - } -} - -// Tracer allows you to add a request/resolver tracer that will be called around the root request, -// calling resolver. This is useful for tracing -func Tracer(tracer graphql.Tracer) Option { - return func(cfg *Config) { - if cfg.tracer == nil { - cfg.tracer = tracer - - } else { - lastResolve := cfg.tracer - cfg.tracer = &tracerWrapper{ - tracer1: lastResolve, - tracer2: tracer, - } - } - - opt := RequestMiddleware(func(ctx context.Context, next func(ctx context.Context) []byte) []byte { - ctx = tracer.StartOperationExecution(ctx) - resp := next(ctx) - tracer.EndOperationExecution(ctx) - - return resp - }) - opt(cfg) - } -} - -type tracerWrapper struct { - tracer1 graphql.Tracer - tracer2 graphql.Tracer -} - -func (tw *tracerWrapper) StartOperationParsing(ctx context.Context) context.Context { - ctx = tw.tracer1.StartOperationParsing(ctx) - ctx = tw.tracer2.StartOperationParsing(ctx) - return ctx -} - -func (tw *tracerWrapper) EndOperationParsing(ctx context.Context) { - tw.tracer2.EndOperationParsing(ctx) - tw.tracer1.EndOperationParsing(ctx) -} - -func (tw *tracerWrapper) StartOperationValidation(ctx context.Context) context.Context { - ctx = tw.tracer1.StartOperationValidation(ctx) - ctx = tw.tracer2.StartOperationValidation(ctx) - return ctx -} - -func (tw *tracerWrapper) EndOperationValidation(ctx context.Context) { - tw.tracer2.EndOperationValidation(ctx) - tw.tracer1.EndOperationValidation(ctx) -} - -func (tw *tracerWrapper) StartOperationExecution(ctx context.Context) context.Context { - ctx = tw.tracer1.StartOperationExecution(ctx) - ctx = tw.tracer2.StartOperationExecution(ctx) - return ctx -} - -func (tw *tracerWrapper) StartFieldExecution(ctx context.Context, field graphql.CollectedField) context.Context { - ctx = tw.tracer1.StartFieldExecution(ctx, field) - ctx = tw.tracer2.StartFieldExecution(ctx, field) - return ctx -} - -func (tw *tracerWrapper) StartFieldResolverExecution(ctx context.Context, rc *graphql.ResolverContext) context.Context { - ctx = tw.tracer1.StartFieldResolverExecution(ctx, rc) - ctx = tw.tracer2.StartFieldResolverExecution(ctx, rc) - return ctx -} - -func (tw *tracerWrapper) StartFieldChildExecution(ctx context.Context) context.Context { - ctx = tw.tracer1.StartFieldChildExecution(ctx) - ctx = tw.tracer2.StartFieldChildExecution(ctx) - return ctx -} - -func (tw *tracerWrapper) EndFieldExecution(ctx context.Context) { - tw.tracer2.EndFieldExecution(ctx) - tw.tracer1.EndFieldExecution(ctx) -} - -func (tw *tracerWrapper) EndOperationExecution(ctx context.Context) { - tw.tracer2.EndOperationExecution(ctx) - tw.tracer1.EndOperationExecution(ctx) -} - -// WebsocketInitFunc is called when the server receives connection init message from the client. -// This can be used to check initial payload to see whether to accept the websocket connection. -func WebsocketInitFunc(websocketInitFunc websocketInitFunc) Option { - return func(cfg *Config) { - cfg.websocketInitFunc = websocketInitFunc - } -} - -// CacheSize sets the maximum size of the query cache. -// If size is less than or equal to 0, the cache is disabled. -func CacheSize(size int) Option { - return func(cfg *Config) { - cfg.cacheSize = size - } -} - -// UploadMaxSize sets the maximum number of bytes used to parse a request body -// as multipart/form-data. -func UploadMaxSize(size int64) Option { - return func(cfg *Config) { - cfg.uploadMaxSize = size - } -} - -// UploadMaxMemory sets the maximum number of bytes used to parse a request body -// as multipart/form-data in memory, with the remainder stored on disk in -// temporary files. -func UploadMaxMemory(size int64) Option { - return func(cfg *Config) { - cfg.uploadMaxMemory = size - } -} - -// WebsocketKeepAliveDuration allows you to reconfigure the keepalive behavior. -// By default, keepalive is enabled with a DefaultConnectionKeepAlivePingInterval -// duration. Set handler.connectionKeepAlivePingInterval = 0 to disable keepalive -// altogether. -func WebsocketKeepAliveDuration(duration time.Duration) Option { - return func(cfg *Config) { - cfg.connectionKeepAlivePingInterval = duration - } -} - -// Add cache that will hold queries for automatic persisted queries (APQ) -func EnablePersistedQueryCache(cache PersistedQueryCache) Option { - return func(cfg *Config) { - cfg.apqCache = cache - } -} - -const DefaultCacheSize = 1000 -const DefaultConnectionKeepAlivePingInterval = 25 * time.Second - -// DefaultUploadMaxMemory is the maximum number of bytes used to parse a request body -// as multipart/form-data in memory, with the remainder stored on disk in -// temporary files. -const DefaultUploadMaxMemory = 32 << 20 - -// DefaultUploadMaxSize is maximum number of bytes used to parse a request body -// as multipart/form-data. -const DefaultUploadMaxSize = 32 << 20 - -func GraphQL(exec graphql.ExecutableSchema, options ...Option) http.HandlerFunc { - cfg := &Config{ - cacheSize: DefaultCacheSize, - uploadMaxMemory: DefaultUploadMaxMemory, - uploadMaxSize: DefaultUploadMaxSize, - connectionKeepAlivePingInterval: DefaultConnectionKeepAlivePingInterval, - upgrader: websocket.Upgrader{ - ReadBufferSize: 1024, - WriteBufferSize: 1024, - }, - } - - for _, option := range options { - option(cfg) - } - - var cache *lru.Cache - if cfg.cacheSize > 0 { - var err error - cache, err = lru.New(cfg.cacheSize) - if err != nil { - // An error is only returned for non-positive cache size - // and we already checked for that. - panic("unexpected error creating cache: " + err.Error()) - } - } - if cfg.tracer == nil { - cfg.tracer = &graphql.NopTracer{} - } - - handler := &graphqlHandler{ - cfg: cfg, - cache: cache, - exec: exec, - } - - return handler.ServeHTTP -} - -var _ http.Handler = (*graphqlHandler)(nil) - -type graphqlHandler struct { - cfg *Config - cache *lru.Cache - exec graphql.ExecutableSchema -} - -func computeQueryHash(query string) string { - b := sha256.Sum256([]byte(query)) - return hex.EncodeToString(b[:]) -} - -func (gh *graphqlHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if r.Method == http.MethodOptions { - w.Header().Set("Allow", "OPTIONS, GET, POST") - w.WriteHeader(http.StatusOK) - return - } - - if strings.Contains(r.Header.Get("Upgrade"), "websocket") { - connectWs(gh.exec, w, r, gh.cfg, gh.cache) - return - } - - w.Header().Set("Content-Type", "application/json") - var reqParams params - switch r.Method { - case http.MethodGet: - reqParams.Query = r.URL.Query().Get("query") - reqParams.OperationName = r.URL.Query().Get("operationName") - - if variables := r.URL.Query().Get("variables"); variables != "" { - if err := jsonDecode(strings.NewReader(variables), &reqParams.Variables); err != nil { - sendErrorf(w, http.StatusBadRequest, "variables could not be decoded") - return - } - } - - if extensions := r.URL.Query().Get("extensions"); extensions != "" { - if err := jsonDecode(strings.NewReader(extensions), &reqParams.Extensions); err != nil { - sendErrorf(w, http.StatusBadRequest, "extensions could not be decoded") - return - } - } - case http.MethodPost: - mediaType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) - if err != nil { - sendErrorf(w, http.StatusBadRequest, "error parsing request Content-Type") - return - } - - switch mediaType { - case "application/json": - if err := jsonDecode(r.Body, &reqParams); err != nil { - sendErrorf(w, http.StatusBadRequest, "json body could not be decoded: "+err.Error()) - return - } - - case "multipart/form-data": - var closers []io.Closer - var tmpFiles []string - defer func() { - for i := len(closers) - 1; 0 <= i; i-- { - _ = closers[i].Close() - } - for _, tmpFile := range tmpFiles { - _ = os.Remove(tmpFile) - } - }() - if err := processMultipart(w, r, &reqParams, &closers, &tmpFiles, gh.cfg.uploadMaxSize, gh.cfg.uploadMaxMemory); err != nil { - sendErrorf(w, http.StatusBadRequest, "multipart body could not be decoded: "+err.Error()) - return - } - default: - sendErrorf(w, http.StatusBadRequest, "unsupported Content-Type: "+mediaType) - return - } - default: - w.WriteHeader(http.StatusMethodNotAllowed) - return - } - - ctx := r.Context() - - var queryHash string - apqRegister := false - apq := reqParams.Extensions != nil && reqParams.Extensions.PersistedQuery != nil - if apq { - // client has enabled apq - queryHash = reqParams.Extensions.PersistedQuery.Sha256 - if gh.cfg.apqCache == nil { - // server has disabled apq - sendErrorf(w, http.StatusOK, errPersistedQueryNotSupported) - return - } - if reqParams.Extensions.PersistedQuery.Version != 1 { - sendErrorf(w, http.StatusOK, "Unsupported persisted query version") - return - } - if reqParams.Query == "" { - // client sent optimistic query hash without query string - query, ok := gh.cfg.apqCache.Get(ctx, queryHash) - if !ok { - sendErrorf(w, http.StatusOK, errPersistedQueryNotFound) - return - } - reqParams.Query = query - } else { - if computeQueryHash(reqParams.Query) != queryHash { - sendErrorf(w, http.StatusOK, "provided sha does not match query") - return - } - apqRegister = true - } - } else if reqParams.Query == "" { - sendErrorf(w, http.StatusUnprocessableEntity, "Must provide query string") - return - } - - var doc *ast.QueryDocument - var cacheHit bool - if gh.cache != nil { - val, ok := gh.cache.Get(reqParams.Query) - if ok { - doc = val.(*ast.QueryDocument) - cacheHit = true - } - } - - ctx, doc, gqlErr := gh.parseOperation(ctx, &parseOperationArgs{ - Query: reqParams.Query, - CachedDoc: doc, - }) - if gqlErr != nil { - sendError(w, http.StatusUnprocessableEntity, gqlErr) - return - } - - ctx, op, vars, listErr := gh.validateOperation(ctx, &validateOperationArgs{ - Doc: doc, - OperationName: reqParams.OperationName, - CacheHit: cacheHit, - R: r, - Variables: reqParams.Variables, - }) - if len(listErr) != 0 { - sendError(w, http.StatusUnprocessableEntity, listErr...) - return - } - - if gh.cache != nil && !cacheHit { - gh.cache.Add(reqParams.Query, doc) - } - - reqCtx, err := gh.cfg.newRequestContext(ctx, gh.exec, doc, op, reqParams.OperationName, reqParams.Query, vars) - if err != nil { - sendErrorf(w, http.StatusBadRequest, "invalid RequestContext was generated: %s", err.Error()) - return - } - ctx = graphql.WithRequestContext(ctx, reqCtx) - - defer func() { - if err := recover(); err != nil { - userErr := reqCtx.Recover(ctx, err) - sendErrorf(w, http.StatusUnprocessableEntity, userErr.Error()) - } - }() - - if gh.cfg.complexityLimitFunc != nil { - reqCtx.ComplexityLimit = gh.cfg.complexityLimitFunc(ctx) - } - - if reqCtx.ComplexityLimit > 0 && reqCtx.OperationComplexity > reqCtx.ComplexityLimit { - sendErrorf(w, http.StatusUnprocessableEntity, "operation has complexity %d, which exceeds the limit of %d", reqCtx.OperationComplexity, reqCtx.ComplexityLimit) - return - } - - if apqRegister && gh.cfg.apqCache != nil { - // Add to persisted query cache - gh.cfg.apqCache.Add(ctx, queryHash, reqParams.Query) - } - - switch op.Operation { - case ast.Query: - b, err := json.Marshal(gh.exec.Query(ctx, op)) - if err != nil { - panic(err) - } - w.Write(b) - case ast.Mutation: - b, err := json.Marshal(gh.exec.Mutation(ctx, op)) - if err != nil { - panic(err) - } - w.Write(b) - default: - sendErrorf(w, http.StatusBadRequest, "unsupported operation type") - } -} - -type parseOperationArgs struct { - Query string - CachedDoc *ast.QueryDocument -} - -func (gh *graphqlHandler) parseOperation(ctx context.Context, args *parseOperationArgs) (context.Context, *ast.QueryDocument, *gqlerror.Error) { - ctx = gh.cfg.tracer.StartOperationParsing(ctx) - defer func() { gh.cfg.tracer.EndOperationParsing(ctx) }() - - if args.CachedDoc != nil { - return ctx, args.CachedDoc, nil - } - - doc, gqlErr := parser.ParseQuery(&ast.Source{Input: args.Query}) - if gqlErr != nil { - return ctx, nil, gqlErr - } - - return ctx, doc, nil -} - -type validateOperationArgs struct { - Doc *ast.QueryDocument - OperationName string - CacheHit bool - R *http.Request - Variables map[string]interface{} -} - -func (gh *graphqlHandler) validateOperation(ctx context.Context, args *validateOperationArgs) (context.Context, *ast.OperationDefinition, map[string]interface{}, gqlerror.List) { - ctx = gh.cfg.tracer.StartOperationValidation(ctx) - defer func() { gh.cfg.tracer.EndOperationValidation(ctx) }() - - if !args.CacheHit { - listErr := validator.Validate(gh.exec.Schema(), args.Doc) - if len(listErr) != 0 { - return ctx, nil, nil, listErr - } - } - - op := args.Doc.Operations.ForName(args.OperationName) - if op == nil { - return ctx, nil, nil, gqlerror.List{gqlerror.Errorf("operation %s not found", args.OperationName)} - } - - if op.Operation != ast.Query && args.R.Method == http.MethodGet { - return ctx, nil, nil, gqlerror.List{gqlerror.Errorf("GET requests only allow query operations")} - } - - vars, err := validator.VariableValues(gh.exec.Schema(), op, args.Variables) - if err != nil { - return ctx, nil, nil, gqlerror.List{err} - } - - return ctx, op, vars, nil -} - -func jsonDecode(r io.Reader, val interface{}) error { - dec := json.NewDecoder(r) - dec.UseNumber() - return dec.Decode(val) -} - -func sendError(w http.ResponseWriter, code int, errors ...*gqlerror.Error) { - w.WriteHeader(code) - b, err := json.Marshal(&graphql.Response{Errors: errors}) - if err != nil { - panic(err) - } - w.Write(b) -} - -func sendErrorf(w http.ResponseWriter, code int, format string, args ...interface{}) { - sendError(w, code, &gqlerror.Error{Message: fmt.Sprintf(format, args...)}) -} - -type bytesReader struct { - s *[]byte - i int64 // current reading index - prevRune int // index of previous rune; or < 0 -} - -func (r *bytesReader) Read(b []byte) (n int, err error) { - if r.s == nil { - return 0, errors.New("byte slice pointer is nil") - } - if r.i >= int64(len(*r.s)) { - return 0, io.EOF - } - r.prevRune = -1 - n = copy(b, (*r.s)[r.i:]) - r.i += int64(n) - return -} - -func processMultipart(w http.ResponseWriter, r *http.Request, request *params, closers *[]io.Closer, tmpFiles *[]string, uploadMaxSize, uploadMaxMemory int64) error { - var err error - if r.ContentLength > uploadMaxSize { - return errors.New("failed to parse multipart form, request body too large") - } - r.Body = http.MaxBytesReader(w, r.Body, uploadMaxSize) - if err = r.ParseMultipartForm(uploadMaxMemory); err != nil { - if strings.Contains(err.Error(), "request body too large") { - return errors.New("failed to parse multipart form, request body too large") - } - return errors.New("failed to parse multipart form") - } - *closers = append(*closers, r.Body) - - if err = jsonDecode(strings.NewReader(r.Form.Get("operations")), &request); err != nil { - return errors.New("operations form field could not be decoded") - } - - var uploadsMap = map[string][]string{} - if err = json.Unmarshal([]byte(r.Form.Get("map")), &uploadsMap); err != nil { - return errors.New("map form field could not be decoded") - } - - var upload graphql.Upload - for key, paths := range uploadsMap { - if len(paths) == 0 { - return fmt.Errorf("invalid empty operations paths list for key %s", key) - } - file, header, err := r.FormFile(key) - if err != nil { - return fmt.Errorf("failed to get key %s from form", key) - } - *closers = append(*closers, file) - - if len(paths) == 1 { - upload = graphql.Upload{ - File: file, - Size: header.Size, - Filename: header.Filename, - } - err = addUploadToOperations(request, upload, key, paths[0]) - if err != nil { - return err - } - } else { - if r.ContentLength < uploadMaxMemory { - fileBytes, err := ioutil.ReadAll(file) - if err != nil { - return fmt.Errorf("failed to read file for key %s", key) - } - for _, path := range paths { - upload = graphql.Upload{ - File: &bytesReader{s: &fileBytes, i: 0, prevRune: -1}, - Size: header.Size, - Filename: header.Filename, - } - err = addUploadToOperations(request, upload, key, path) - if err != nil { - return err - } - } - } else { - tmpFile, err := ioutil.TempFile(os.TempDir(), "gqlgen-") - if err != nil { - return fmt.Errorf("failed to create temp file for key %s", key) - } - tmpName := tmpFile.Name() - *tmpFiles = append(*tmpFiles, tmpName) - _, err = io.Copy(tmpFile, file) - if err != nil { - if err := tmpFile.Close(); err != nil { - return fmt.Errorf("failed to copy to temp file and close temp file for key %s", key) - } - return fmt.Errorf("failed to copy to temp file for key %s", key) - } - if err := tmpFile.Close(); err != nil { - return fmt.Errorf("failed to close temp file for key %s", key) - } - for _, path := range paths { - pathTmpFile, err := os.Open(tmpName) - if err != nil { - return fmt.Errorf("failed to open temp file for key %s", key) - } - *closers = append(*closers, pathTmpFile) - upload = graphql.Upload{ - File: pathTmpFile, - Size: header.Size, - Filename: header.Filename, - } - err = addUploadToOperations(request, upload, key, path) - if err != nil { - return err - } - } - } - } - } - return nil -} - -func addUploadToOperations(request *params, upload graphql.Upload, key, path string) error { - if !strings.HasPrefix(path, "variables.") { - return fmt.Errorf("invalid operations paths for key %s", key) - } - - var ptr interface{} = request.Variables - parts := strings.Split(path, ".") - - // skip the first part (variables) because we started there - for i, p := range parts[1:] { - last := i == len(parts)-2 - if ptr == nil { - return fmt.Errorf("path is missing \"variables.\" prefix, key: %s, path: %s", key, path) - } - if index, parseNbrErr := strconv.Atoi(p); parseNbrErr == nil { - if last { - ptr.([]interface{})[index] = upload - } else { - ptr = ptr.([]interface{})[index] - } - } else { - if last { - ptr.(map[string]interface{})[p] = upload - } else { - ptr = ptr.(map[string]interface{})[p] - } - } - } - - return nil -} diff --git a/handler/graphql_test.go b/handler/graphql_test.go deleted file mode 100644 index 06ba718429a..00000000000 --- a/handler/graphql_test.go +++ /dev/null @@ -1,832 +0,0 @@ -package handler - -import ( - "bytes" - "context" - "fmt" - "io" - "io/ioutil" - "mime/multipart" - "net/http" - "net/http/httptest" - "os" - "strings" - "sync" - "testing" - - "github.com/99designs/gqlgen/graphql" - lru "github.com/hashicorp/golang-lru" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/vektah/gqlparser/ast" -) - -func TestHandlerPOST(t *testing.T) { - h := GraphQL(&executableSchemaStub{}) - - t.Run("success", func(t *testing.T) { - resp := doRequest(h, "POST", "/graphql", `{"query":"{ me { name } }"}`) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - }) - - t.Run("query caching", func(t *testing.T) { - // Run enough unique queries to evict a bunch of them - for i := 0; i < 2000; i++ { - query := `{"query":"` + strings.Repeat(" ", i) + "{ me { name } }" + `"}` - resp := doRequest(h, "POST", "/graphql", query) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - } - - t.Run("evicted queries run", func(t *testing.T) { - query := `{"query":"` + strings.Repeat(" ", 0) + "{ me { name } }" + `"}` - resp := doRequest(h, "POST", "/graphql", query) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - }) - - t.Run("non-evicted queries run", func(t *testing.T) { - query := `{"query":"` + strings.Repeat(" ", 1999) + "{ me { name } }" + `"}` - resp := doRequest(h, "POST", "/graphql", query) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - }) - }) - - t.Run("decode failure", func(t *testing.T) { - resp := doRequest(h, "POST", "/graphql", "notjson") - assert.Equal(t, http.StatusBadRequest, resp.Code) - assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") - assert.Equal(t, `{"errors":[{"message":"json body could not be decoded: invalid character 'o' in literal null (expecting 'u')"}],"data":null}`, resp.Body.String()) - }) - - t.Run("parse failure", func(t *testing.T) { - resp := doRequest(h, "POST", "/graphql", `{"query": "!"}`) - assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) - assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") - assert.Equal(t, `{"errors":[{"message":"Unexpected !","locations":[{"line":1,"column":1}]}],"data":null}`, resp.Body.String()) - }) - - t.Run("validation failure", func(t *testing.T) { - resp := doRequest(h, "POST", "/graphql", `{"query": "{ me { title }}"}`) - assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) - assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") - assert.Equal(t, `{"errors":[{"message":"Cannot query field \"title\" on type \"User\".","locations":[{"line":1,"column":8}]}],"data":null}`, resp.Body.String()) - }) - - t.Run("invalid variable", func(t *testing.T) { - resp := doRequest(h, "POST", "/graphql", `{"query": "query($id:Int!){user(id:$id){name}}","variables":{"id":false}}`) - assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) - assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") - assert.Equal(t, `{"errors":[{"message":"cannot use bool as Int","path":["variable","id"]}],"data":null}`, resp.Body.String()) - }) - - t.Run("execution failure", func(t *testing.T) { - resp := doRequest(h, "POST", "/graphql", `{"query": "mutation { me { name } }"}`) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") - assert.Equal(t, `{"errors":[{"message":"mutations are not supported"}],"data":null}`, resp.Body.String()) - }) - - t.Run("validate content type", func(t *testing.T) { - doReq := func(handler http.Handler, method string, target string, body string, contentType string) *httptest.ResponseRecorder { - r := httptest.NewRequest(method, target, strings.NewReader(body)) - if contentType != "" { - r.Header.Set("Content-Type", contentType) - } - w := httptest.NewRecorder() - - handler.ServeHTTP(w, r) - return w - } - - validContentTypes := []string{ - "application/json", - "application/json; charset=utf-8", - } - - for _, contentType := range validContentTypes { - t.Run(fmt.Sprintf("allow for content type %s", contentType), func(t *testing.T) { - resp := doReq(h, "POST", "/graphql", `{"query":"{ me { name } }"}`, contentType) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - }) - } - - invalidContentTypes := []struct{ contentType, expectedError string }{ - {"", "error parsing request Content-Type"}, - {"text/plain", "unsupported Content-Type: text/plain"}, - - // These content types are currently not supported, but they are supported by other GraphQL servers, like express-graphql. - {"application/x-www-form-urlencoded", "unsupported Content-Type: application/x-www-form-urlencoded"}, - {"application/graphql", "unsupported Content-Type: application/graphql"}, - } - - for _, tc := range invalidContentTypes { - t.Run(fmt.Sprintf("reject for content type %s", tc.contentType), func(t *testing.T) { - resp := doReq(h, "POST", "/graphql", `{"query":"{ me { name } }"}`, tc.contentType) - assert.Equal(t, http.StatusBadRequest, resp.Code) - assert.Equal(t, fmt.Sprintf(`{"errors":[{"message":"%s"}],"data":null}`, tc.expectedError), resp.Body.String()) - }) - } - }) -} - -func TestHandlerGET(t *testing.T) { - h := GraphQL(&executableSchemaStub{}) - - t.Run("success", func(t *testing.T) { - resp := doRequest(h, "GET", "/graphql?query={me{name}}", ``) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - }) - - t.Run("decode failure", func(t *testing.T) { - resp := doRequest(h, "GET", "/graphql?query=me{id}&variables=notjson", "") - assert.Equal(t, http.StatusBadRequest, resp.Code) - assert.Equal(t, `{"errors":[{"message":"variables could not be decoded"}],"data":null}`, resp.Body.String()) - }) - - t.Run("invalid variable", func(t *testing.T) { - resp := doRequest(h, "GET", `/graphql?query=query($id:Int!){user(id:$id){name}}&variables={"id":false}`, "") - assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) - assert.Equal(t, `{"errors":[{"message":"cannot use bool as Int","path":["variable","id"]}],"data":null}`, resp.Body.String()) - }) - - t.Run("parse failure", func(t *testing.T) { - resp := doRequest(h, "GET", "/graphql?query=!", "") - assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) - assert.Equal(t, `{"errors":[{"message":"Unexpected !","locations":[{"line":1,"column":1}]}],"data":null}`, resp.Body.String()) - }) - - t.Run("no mutations", func(t *testing.T) { - resp := doRequest(h, "GET", "/graphql?query=mutation{me{name}}", "") - assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) - assert.Equal(t, `{"errors":[{"message":"GET requests only allow query operations"}],"data":null}`, resp.Body.String()) - }) -} - -func TestHandlerOptions(t *testing.T) { - h := GraphQL(&executableSchemaStub{}) - - resp := doRequest(h, "OPTIONS", "/graphql?query={me{name}}", ``) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, "OPTIONS, GET, POST", resp.Header().Get("Allow")) -} - -func TestHandlerHead(t *testing.T) { - h := GraphQL(&executableSchemaStub{}) - - resp := doRequest(h, "HEAD", "/graphql?query={me{name}}", ``) - assert.Equal(t, http.StatusMethodNotAllowed, resp.Code) -} - -func TestHandlerComplexity(t *testing.T) { - t.Run("static complexity", func(t *testing.T) { - h := GraphQL(&executableSchemaStub{}, ComplexityLimit(2)) - - t.Run("below complexity limit", func(t *testing.T) { - resp := doRequest(h, "POST", "/graphql", `{"query":"{ me { name } }"}`) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - }) - - t.Run("above complexity limit", func(t *testing.T) { - resp := doRequest(h, "POST", "/graphql", `{"query":"{ a: me { name } b: me { name } }"}`) - assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) - assert.Equal(t, `{"errors":[{"message":"operation has complexity 4, which exceeds the limit of 2"}],"data":null}`, resp.Body.String()) - }) - }) - - t.Run("dynamic complexity", func(t *testing.T) { - h := GraphQL(&executableSchemaStub{}, ComplexityLimitFunc(func(ctx context.Context) int { - reqCtx := graphql.GetRequestContext(ctx) - if strings.Contains(reqCtx.RawQuery, "dummy") { - return 4 - } - return 2 - })) - - t.Run("below complexity limit", func(t *testing.T) { - resp := doRequest(h, "POST", "/graphql", `{"query":"{ me { name } }"}`) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - }) - - t.Run("above complexity limit", func(t *testing.T) { - resp := doRequest(h, "POST", "/graphql", `{"query":"{ a: me { name } b: me { name } }"}`) - assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) - assert.Equal(t, `{"errors":[{"message":"operation has complexity 4, which exceeds the limit of 2"}],"data":null}`, resp.Body.String()) - }) - - t.Run("within dynamic complexity limit", func(t *testing.T) { - resp := doRequest(h, "POST", "/graphql", `{"query":"{ a: me { name } dummy: me { name } }"}`) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - }) - }) -} - -func TestFileUpload(t *testing.T) { - - t.Run("valid single file upload", func(t *testing.T) { - mock := &executableSchemaMock{ - MutationFunc: func(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - require.Equal(t, len(op.VariableDefinitions), 1) - require.Equal(t, op.VariableDefinitions[0].Variable, "file") - return &graphql.Response{Data: []byte(`{"singleUpload":{"id":1}}`)} - }, - } - handler := GraphQL(mock) - - operations := `{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id } }", "variables": { "file": null } }` - mapData := `{ "0": ["variables.file"] }` - files := []file{ - { - mapKey: "0", - name: "a.txt", - content: "test1", - }, - } - req := createUploadRequest(t, operations, mapData, files) - - resp := httptest.NewRecorder() - handler.ServeHTTP(resp, req) - require.Equal(t, http.StatusOK, resp.Code) - require.Equal(t, `{"data":{"singleUpload":{"id":1}}}`, resp.Body.String()) - }) - - t.Run("valid single file upload with payload", func(t *testing.T) { - mock := &executableSchemaMock{ - MutationFunc: func(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - require.Equal(t, len(op.VariableDefinitions), 1) - require.Equal(t, op.VariableDefinitions[0].Variable, "req") - return &graphql.Response{Data: []byte(`{"singleUploadWithPayload":{"id":1}}`)} - }, - } - handler := GraphQL(mock) - - operations := `{ "query": "mutation ($req: UploadFile!) { singleUploadWithPayload(req: $req) { id } }", "variables": { "req": {"file": null, "id": 1 } } }` - mapData := `{ "0": ["variables.req.file"] }` - files := []file{ - { - mapKey: "0", - name: "a.txt", - content: "test1", - }, - } - req := createUploadRequest(t, operations, mapData, files) - - resp := httptest.NewRecorder() - handler.ServeHTTP(resp, req) - require.Equal(t, http.StatusOK, resp.Code) - require.Equal(t, `{"data":{"singleUploadWithPayload":{"id":1}}}`, resp.Body.String()) - }) - - t.Run("valid file list upload", func(t *testing.T) { - mock := &executableSchemaMock{ - MutationFunc: func(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - require.Equal(t, len(op.VariableDefinitions), 1) - require.Equal(t, op.VariableDefinitions[0].Variable, "files") - return &graphql.Response{Data: []byte(`{"multipleUpload":[{"id":1},{"id":2}]}`)} - }, - } - handler := GraphQL(mock) - - operations := `{ "query": "mutation($files: [Upload!]!) { multipleUpload(files: $files) { id } }", "variables": { "files": [null, null] } }` - mapData := `{ "0": ["variables.files.0"], "1": ["variables.files.1"] }` - files := []file{ - { - mapKey: "0", - name: "a.txt", - content: "test1", - }, - { - mapKey: "1", - name: "b.txt", - content: "test2", - }, - } - req := createUploadRequest(t, operations, mapData, files) - - resp := httptest.NewRecorder() - handler.ServeHTTP(resp, req) - require.Equal(t, http.StatusOK, resp.Code) - require.Equal(t, `{"data":{"multipleUpload":[{"id":1},{"id":2}]}}`, resp.Body.String()) - }) - - t.Run("valid file list upload with payload", func(t *testing.T) { - mock := &executableSchemaMock{ - MutationFunc: func(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - require.Equal(t, len(op.VariableDefinitions), 1) - require.Equal(t, op.VariableDefinitions[0].Variable, "req") - return &graphql.Response{Data: []byte(`{"multipleUploadWithPayload":[{"id":1},{"id":2}]}`)} - }, - } - handler := GraphQL(mock) - - operations := `{ "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) { id } }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } }` - mapData := `{ "0": ["variables.req.0.file"], "1": ["variables.req.1.file"] }` - files := []file{ - { - mapKey: "0", - name: "a.txt", - content: "test1", - }, - { - mapKey: "1", - name: "b.txt", - content: "test2", - }, - } - req := createUploadRequest(t, operations, mapData, files) - - resp := httptest.NewRecorder() - handler.ServeHTTP(resp, req) - require.Equal(t, http.StatusOK, resp.Code) - require.Equal(t, `{"data":{"multipleUploadWithPayload":[{"id":1},{"id":2}]}}`, resp.Body.String()) - }) - - t.Run("valid file list upload with payload and file reuse", func(t *testing.T) { - test := func(uploadMaxMemory int64) { - mock := &executableSchemaMock{ - MutationFunc: func(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - require.Equal(t, len(op.VariableDefinitions), 1) - require.Equal(t, op.VariableDefinitions[0].Variable, "req") - return &graphql.Response{Data: []byte(`{"multipleUploadWithPayload":[{"id":1},{"id":2}]}`)} - }, - } - maxMemory := UploadMaxMemory(uploadMaxMemory) - handler := GraphQL(mock, maxMemory) - - operations := `{ "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) { id } }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } }` - mapData := `{ "0": ["variables.req.0.file", "variables.req.1.file"] }` - files := []file{ - { - mapKey: "0", - name: "a.txt", - content: "test1", - }, - } - req := createUploadRequest(t, operations, mapData, files) - - resp := httptest.NewRecorder() - handler.ServeHTTP(resp, req) - require.Equal(t, http.StatusOK, resp.Code) - require.Equal(t, `{"data":{"multipleUploadWithPayload":[{"id":1},{"id":2}]}}`, resp.Body.String()) - } - - t.Run("payload smaller than UploadMaxMemory, stored in memory", func(t *testing.T) { - test(5000) - }) - - t.Run("payload bigger than UploadMaxMemory, persisted to disk", func(t *testing.T) { - test(2) - }) - }) -} - -func TestProcessMultipart(t *testing.T) { - validOperations := `{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id } }", "variables": { "file": null } }` - validMap := `{ "0": ["variables.file"] }` - validFiles := []file{ - { - mapKey: "0", - name: "a.txt", - content: "test1", - }, - } - - cleanUp := func(t *testing.T, closers []io.Closer, tmpFiles []string) { - for i := len(closers) - 1; 0 <= i; i-- { - err := closers[i].Close() - require.Nil(t, err) - } - for _, tmpFiles := range tmpFiles { - err := os.Remove(tmpFiles) - require.Nil(t, err) - } - } - - t.Run("fail to parse multipart", func(t *testing.T) { - req := &http.Request{ - Method: "POST", - Header: http.Header{"Content-Type": {`multipart/form-data; boundary="foo123"`}}, - Body: ioutil.NopCloser(new(bytes.Buffer)), - } - var reqParams params - var closers []io.Closer - var tmpFiles []string - w := httptest.NewRecorder() - err := processMultipart(w, req, &reqParams, &closers, &tmpFiles, DefaultUploadMaxSize, DefaultUploadMaxMemory) - require.NotNil(t, err) - require.Equal(t, err.Error(), "failed to parse multipart form") - cleanUp(t, closers, tmpFiles) - }) - - t.Run("fail parse operation", func(t *testing.T) { - operations := `invalid operation` - req := createUploadRequest(t, operations, validMap, validFiles) - - var reqParams params - var closers []io.Closer - var tmpFiles []string - w := httptest.NewRecorder() - err := processMultipart(w, req, &reqParams, &closers, &tmpFiles, DefaultUploadMaxSize, DefaultUploadMaxMemory) - require.NotNil(t, err) - require.Equal(t, err.Error(), "operations form field could not be decoded") - cleanUp(t, closers, tmpFiles) - }) - - t.Run("fail parse map", func(t *testing.T) { - mapData := `invalid map` - req := createUploadRequest(t, validOperations, mapData, validFiles) - - var reqParams params - var closers []io.Closer - var tmpFiles []string - w := httptest.NewRecorder() - err := processMultipart(w, req, &reqParams, &closers, &tmpFiles, DefaultUploadMaxSize, DefaultUploadMaxMemory) - require.NotNil(t, err) - require.Equal(t, err.Error(), "map form field could not be decoded") - cleanUp(t, closers, tmpFiles) - }) - - t.Run("fail missing file", func(t *testing.T) { - var files []file - req := createUploadRequest(t, validOperations, validMap, files) - - var reqParams params - var closers []io.Closer - var tmpFiles []string - w := httptest.NewRecorder() - err := processMultipart(w, req, &reqParams, &closers, &tmpFiles, DefaultUploadMaxSize, DefaultUploadMaxMemory) - require.NotNil(t, err) - require.Equal(t, err.Error(), "failed to get key 0 from form") - cleanUp(t, closers, tmpFiles) - }) - - t.Run("fail map entry with invalid operations paths prefix", func(t *testing.T) { - mapData := `{ "0": ["var.file"] }` - req := createUploadRequest(t, validOperations, mapData, validFiles) - - var reqParams params - var closers []io.Closer - var tmpFiles []string - w := httptest.NewRecorder() - err := processMultipart(w, req, &reqParams, &closers, &tmpFiles, DefaultUploadMaxSize, DefaultUploadMaxMemory) - require.NotNil(t, err) - require.Equal(t, err.Error(), "invalid operations paths for key 0") - cleanUp(t, closers, tmpFiles) - }) - - t.Run("fail parse request big body", func(t *testing.T) { - req := createUploadRequest(t, validOperations, validMap, validFiles) - - var reqParams params - var closers []io.Closer - var tmpFiles []string - w := httptest.NewRecorder() - var smallMaxSize int64 = 2 - err := processMultipart(w, req, &reqParams, &closers, &tmpFiles, smallMaxSize, DefaultUploadMaxMemory) - require.NotNil(t, err) - require.Equal(t, err.Error(), "failed to parse multipart form, request body too large") - cleanUp(t, closers, tmpFiles) - }) - - t.Run("valid request", func(t *testing.T) { - req := createUploadRequest(t, validOperations, validMap, validFiles) - - var reqParams params - var closers []io.Closer - var tmpFiles []string - w := httptest.NewRecorder() - err := processMultipart(w, req, &reqParams, &closers, &tmpFiles, DefaultUploadMaxSize, DefaultUploadMaxMemory) - require.Nil(t, err) - require.Equal(t, "mutation ($file: Upload!) { singleUpload(file: $file) { id } }", reqParams.Query) - require.Equal(t, "", reqParams.OperationName) - require.Equal(t, 1, len(reqParams.Variables)) - require.NotNil(t, reqParams.Variables["file"]) - reqParamsFile, ok := reqParams.Variables["file"].(graphql.Upload) - require.True(t, ok) - require.Equal(t, "a.txt", reqParamsFile.Filename) - require.Equal(t, int64(len("test1")), reqParamsFile.Size) - content, err := ioutil.ReadAll(reqParamsFile.File) - require.Nil(t, err) - require.Equal(t, "test1", string(content)) - cleanUp(t, closers, tmpFiles) - }) - - t.Run("valid file list upload with payload and file reuse", func(t *testing.T) { - operations := `{ "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) { id } }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } }` - mapData := `{ "0": ["variables.req.0.file", "variables.req.1.file"] }` - files := []file{ - { - mapKey: "0", - name: "a.txt", - content: "test1", - }, - } - req := createUploadRequest(t, operations, mapData, files) - - test := func(uploadMaxMemory int64) { - var reqParams params - var closers []io.Closer - var tmpFiles []string - w := httptest.NewRecorder() - err := processMultipart(w, req, &reqParams, &closers, &tmpFiles, DefaultUploadMaxSize, uploadMaxMemory) - require.Nil(t, err) - require.Equal(t, "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) { id } }", reqParams.Query) - require.Equal(t, "", reqParams.OperationName) - require.Equal(t, 1, len(reqParams.Variables)) - require.NotNil(t, reqParams.Variables["req"]) - reqParamsFile, ok := reqParams.Variables["req"].([]interface{}) - require.True(t, ok) - require.Equal(t, 2, len(reqParamsFile)) - for i, item := range reqParamsFile { - itemMap := item.(map[string]interface{}) - require.Equal(t, fmt.Sprint(itemMap["id"]), fmt.Sprint(i+1)) - file := itemMap["file"].(graphql.Upload) - require.Equal(t, "a.txt", file.Filename) - require.Equal(t, int64(len("test1")), file.Size) - require.Nil(t, err) - content, err := ioutil.ReadAll(file.File) - require.Nil(t, err) - require.Equal(t, "test1", string(content)) - } - cleanUp(t, closers, tmpFiles) - } - - t.Run("payload smaller than UploadMaxMemory, stored in memory", func(t *testing.T) { - test(5000) - }) - - t.Run("payload bigger than UploadMaxMemory, persisted to disk", func(t *testing.T) { - test(2) - }) - }) -} - -func TestAddUploadToOperations(t *testing.T) { - key := "0" - - t.Run("fail missing all variables", func(t *testing.T) { - file, _ := os.Open("path/to/file") - request := ¶ms{} - - upload := graphql.Upload{ - File: file, - Filename: "a.txt", - Size: int64(5), - } - path := "variables.req.0.file" - err := addUploadToOperations(request, upload, key, path) - require.NotNil(t, err) - require.Equal(t, "path is missing \"variables.\" prefix, key: 0, path: variables.req.0.file", err.Error()) - }) - - t.Run("valid variable", func(t *testing.T) { - file, _ := os.Open("path/to/file") - request := ¶ms{ - Variables: map[string]interface{}{ - "file": nil, - }, - } - - upload := graphql.Upload{ - File: file, - Filename: "a.txt", - Size: int64(5), - } - - expected := ¶ms{ - Variables: map[string]interface{}{ - "file": upload, - }, - } - - path := "variables.file" - err := addUploadToOperations(request, upload, key, path) - require.Nil(t, err) - - require.Equal(t, request, expected) - }) - - t.Run("valid nested variable", func(t *testing.T) { - file, _ := os.Open("path/to/file") - request := ¶ms{ - Variables: map[string]interface{}{ - "req": []interface{}{ - map[string]interface{}{ - "file": nil, - }, - }, - }, - } - - upload := graphql.Upload{ - File: file, - Filename: "a.txt", - Size: int64(5), - } - - expected := ¶ms{ - Variables: map[string]interface{}{ - "req": []interface{}{ - map[string]interface{}{ - "file": upload, - }, - }, - }, - } - - path := "variables.req.0.file" - err := addUploadToOperations(request, upload, key, path) - require.Nil(t, err) - - require.Equal(t, request, expected) - }) -} - -type file struct { - mapKey string - name string - content string -} - -func createUploadRequest(t *testing.T, operations, mapData string, files []file) *http.Request { - bodyBuf := &bytes.Buffer{} - bodyWriter := multipart.NewWriter(bodyBuf) - - err := bodyWriter.WriteField("operations", operations) - require.NoError(t, err) - - err = bodyWriter.WriteField("map", mapData) - require.NoError(t, err) - - for i := range files { - ff, err := bodyWriter.CreateFormFile(files[i].mapKey, files[i].name) - require.NoError(t, err) - _, err = ff.Write([]byte(files[i].content)) - require.NoError(t, err) - } - err = bodyWriter.Close() - require.NoError(t, err) - - req, err := http.NewRequest("POST", "/graphql", bodyBuf) - require.NoError(t, err) - - req.Header.Set("Content-Type", bodyWriter.FormDataContentType()) - return req -} - -func doRequest(handler http.Handler, method string, target string, body string) *httptest.ResponseRecorder { - r := httptest.NewRequest(method, target, strings.NewReader(body)) - r.Header.Set("Content-Type", "application/json") - w := httptest.NewRecorder() - - handler.ServeHTTP(w, r) - return w -} - -func TestBytesRead(t *testing.T) { - t.Run("test concurrency", func(t *testing.T) { - // Test for the race detector, to verify a Read that doesn't yield any bytes - // is okay to use from multiple goroutines. This was our historic behavior. - // See golang.org/issue/7856 - r := bytesReader{s: &([]byte{})} - var wg sync.WaitGroup - for i := 0; i < 5; i++ { - wg.Add(2) - go func() { - defer wg.Done() - var buf [1]byte - r.Read(buf[:]) - }() - go func() { - defer wg.Done() - r.Read(nil) - }() - } - wg.Wait() - }) - - t.Run("fail to read if pointer is nil", func(t *testing.T) { - n, err := (&bytesReader{}).Read(nil) - require.Equal(t, 0, n) - require.NotNil(t, err) - require.Equal(t, "byte slice pointer is nil", err.Error()) - }) - - t.Run("read using buffer", func(t *testing.T) { - data := []byte("0123456789") - r := bytesReader{s: &data} - - got := make([]byte, 0, 11) - buf := make([]byte, 1) - for { - n, err := r.Read(buf) - if n < 0 { - require.Fail(t, "unexpected bytes read size") - } - got = append(got, buf[:n]...) - if err != nil { - if err == io.EOF { - break - } - require.Fail(t, "unexpected error while reading", err.Error()) - } - } - require.Equal(t, "0123456789", string(got)) - }) - - t.Run("read updated pointer value", func(t *testing.T) { - data := []byte("0123456789") - pointer := &data - r := bytesReader{s: pointer} - data[2] = []byte("9")[0] - - got := make([]byte, 0, 11) - buf := make([]byte, 1) - for { - n, err := r.Read(buf) - if n < 0 { - require.Fail(t, "unexpected bytes read size") - } - got = append(got, buf[:n]...) - if err != nil { - if err == io.EOF { - break - } - require.Fail(t, "unexpected error while reading", err.Error()) - } - } - require.Equal(t, "0193456789", string(got)) - }) -} - -type memoryPersistedQueryCache struct { - cache *lru.Cache -} - -func newMemoryPersistedQueryCache(size int) (*memoryPersistedQueryCache, error) { - cache, err := lru.New(size) - return &memoryPersistedQueryCache{cache: cache}, err -} - -func (c *memoryPersistedQueryCache) Add(ctx context.Context, hash string, query string) { - c.cache.Add(hash, query) -} - -func (c *memoryPersistedQueryCache) Get(ctx context.Context, hash string) (string, bool) { - val, ok := c.cache.Get(hash) - if !ok { - return "", ok - } - return val.(string), ok -} -func TestAutomaticPersistedQuery(t *testing.T) { - cache, err := newMemoryPersistedQueryCache(1000) - require.NoError(t, err) - h := GraphQL(&executableSchemaStub{}, EnablePersistedQueryCache(cache)) - t.Run("automatic persisted query POST", func(t *testing.T) { - // normal queries should be unaffected - resp := doRequest(h, "POST", "/graphql", `{"query":"{ me { name } }"}`) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - - // first pass: optimistic hash without query string - resp = doRequest(h, "POST", "/graphql", `{"extensions":{"persistedQuery":{"sha256Hash":"b8d9506e34c83b0e53c2aa463624fcea354713bc38f95276e6f0bd893ffb5b88","version":1}}}`) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"errors":[{"message":"PersistedQueryNotFound"}],"data":null}`, resp.Body.String()) - // second pass: query with query string and query hash - resp = doRequest(h, "POST", "/graphql", `{"query":"{ me { name } }", "extensions":{"persistedQuery":{"sha256Hash":"b8d9506e34c83b0e53c2aa463624fcea354713bc38f95276e6f0bd893ffb5b88","version":1}}}`) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - // future requests without query string - resp = doRequest(h, "POST", "/graphql", `{"extensions":{"persistedQuery":{"sha256Hash":"b8d9506e34c83b0e53c2aa463624fcea354713bc38f95276e6f0bd893ffb5b88","version":1}}}`) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - }) - - t.Run("automatic persisted query GET", func(t *testing.T) { - // normal queries should be unaffected - resp := doRequest(h, "GET", "/graphql?query={me{name}}", "") - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - - // first pass: optimistic hash without query string - resp = doRequest(h, "GET", `/graphql?extensions={"persistedQuery":{"version":1,"sha256Hash":"b58723c4fd7ce18043ae53635b304ba6cee765a67009645b04ca01e80ce1c065"}}`, "") - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"errors":[{"message":"PersistedQueryNotFound"}],"data":null}`, resp.Body.String()) - // second pass: query with query string and query hash - resp = doRequest(h, "GET", `/graphql?query={me{name}}&extensions={"persistedQuery":{"sha256Hash":"b58723c4fd7ce18043ae53635b304ba6cee765a67009645b04ca01e80ce1c065","version":1}}}`, "") - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - // future requests without query string - resp = doRequest(h, "GET", `/graphql?extensions={"persistedQuery":{"version":1,"sha256Hash":"b58723c4fd7ce18043ae53635b304ba6cee765a67009645b04ca01e80ce1c065"}}`, "") - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) - }) -} diff --git a/handler/handler.go b/handler/handler.go new file mode 100644 index 00000000000..c1d2b649ac3 --- /dev/null +++ b/handler/handler.go @@ -0,0 +1,247 @@ +package handler + +import ( + "context" + "net/http" + "time" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/extension" + "github.com/99designs/gqlgen/graphql/handler/lru" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/99designs/gqlgen/graphql/playground" + "github.com/gorilla/websocket" +) + +// Deprecated: switch to graphql/handler.New +func GraphQL(exec graphql.ExecutableSchema, options ...Option) http.HandlerFunc { + var cfg Config + cfg.cacheSize = 1000 + + for _, option := range options { + option(&cfg) + } + + srv := handler.New(exec) + + srv.AddTransport(transport.Websocket{ + Upgrader: cfg.upgrader, + InitFunc: cfg.websocketInitFunc, + KeepAlivePingInterval: cfg.connectionKeepAlivePingInterval, + }) + srv.AddTransport(transport.Options{}) + srv.AddTransport(transport.GET{}) + srv.AddTransport(transport.POST{}) + srv.AddTransport(transport.MultipartForm{ + MaxUploadSize: cfg.uploadMaxSize, + MaxMemory: cfg.uploadMaxMemory, + }) + + if cfg.cacheSize != 0 { + srv.SetQueryCache(lru.New(cfg.cacheSize)) + } + if cfg.recover != nil { + srv.SetRecoverFunc(cfg.recover) + } + if cfg.errorPresenter != nil { + srv.SetErrorPresenter(cfg.errorPresenter) + } + for _, hook := range cfg.fieldHooks { + srv.AroundFields(hook) + } + for _, hook := range cfg.requestHooks { + srv.AroundResponses(hook) + } + if cfg.complexityLimit != 0 { + srv.Use(extension.FixedComplexityLimit(cfg.complexityLimit)) + } else if cfg.complexityLimitFunc != nil { + srv.Use(&extension.ComplexityLimit{ + Func: func(ctx context.Context, rc *graphql.OperationContext) int { + return cfg.complexityLimitFunc(graphql.WithOperationContext(ctx, rc)) + }, + }) + } + if !cfg.disableIntrospection { + srv.Use(extension.Introspection{}) + } + if cfg.apqCache != nil { + srv.Use(extension.AutomaticPersistedQuery{Cache: apqAdapter{cfg.apqCache}}) + } + return srv.ServeHTTP +} + +// Deprecated: switch to graphql/handler.New +type Config struct { + cacheSize int + upgrader websocket.Upgrader + websocketInitFunc transport.WebsocketInitFunc + connectionKeepAlivePingInterval time.Duration + recover graphql.RecoverFunc + errorPresenter graphql.ErrorPresenterFunc + fieldHooks []graphql.FieldMiddleware + requestHooks []graphql.ResponseMiddleware + complexityLimit int + complexityLimitFunc func(ctx context.Context) int + disableIntrospection bool + uploadMaxMemory int64 + uploadMaxSize int64 + apqCache PersistedQueryCache +} + +// Deprecated: switch to graphql/handler.New +type Option func(cfg *Config) + +// Deprecated: switch to graphql/handler.New +func WebsocketUpgrader(upgrader websocket.Upgrader) Option { + return func(cfg *Config) { + cfg.upgrader = upgrader + } +} + +// Deprecated: switch to graphql/handler.New +func RecoverFunc(recover graphql.RecoverFunc) Option { + return func(cfg *Config) { + cfg.recover = recover + } +} + +// ErrorPresenter transforms errors found while resolving into errors that will be returned to the user. It provides +// a good place to add any extra fields, like error.type, that might be desired by your frontend. Check the default +// implementation in graphql.DefaultErrorPresenter for an example. +// Deprecated: switch to graphql/handler.New +func ErrorPresenter(f graphql.ErrorPresenterFunc) Option { + return func(cfg *Config) { + cfg.errorPresenter = f + } +} + +// IntrospectionEnabled = false will forbid clients from calling introspection endpoints. Can be useful in prod when you dont +// want clients introspecting the full schema. +// Deprecated: switch to graphql/handler.New +func IntrospectionEnabled(enabled bool) Option { + return func(cfg *Config) { + cfg.disableIntrospection = !enabled + } +} + +// ComplexityLimit sets a maximum query complexity that is allowed to be executed. +// If a query is submitted that exceeds the limit, a 422 status code will be returned. +// Deprecated: switch to graphql/handler.New +func ComplexityLimit(limit int) Option { + return func(cfg *Config) { + cfg.complexityLimit = limit + } +} + +// ComplexityLimitFunc allows you to define a function to dynamically set the maximum query complexity that is allowed +// to be executed. +// If a query is submitted that exceeds the limit, a 422 status code will be returned. +// Deprecated: switch to graphql/handler.New +func ComplexityLimitFunc(complexityLimitFunc func(ctx context.Context) int) Option { + return func(cfg *Config) { + cfg.complexityLimitFunc = complexityLimitFunc + } +} + +// ResolverMiddleware allows you to define a function that will be called around every resolver, +// useful for logging. +// Deprecated: switch to graphql/handler.New +func ResolverMiddleware(middleware graphql.FieldMiddleware) Option { + return func(cfg *Config) { + cfg.fieldHooks = append(cfg.fieldHooks, middleware) + } +} + +// RequestMiddleware allows you to define a function that will be called around the root request, +// after the query has been parsed. This is useful for logging +// Deprecated: switch to graphql/handler.New +func RequestMiddleware(middleware graphql.ResponseMiddleware) Option { + return func(cfg *Config) { + cfg.requestHooks = append(cfg.requestHooks, middleware) + } +} + +// WebsocketInitFunc is called when the server receives connection init message from the client. +// This can be used to check initial payload to see whether to accept the websocket connection. +// Deprecated: switch to graphql/handler.New +func WebsocketInitFunc(websocketInitFunc transport.WebsocketInitFunc) Option { + return func(cfg *Config) { + cfg.websocketInitFunc = websocketInitFunc + } +} + +// CacheSize sets the maximum size of the query cache. +// If size is less than or equal to 0, the cache is disabled. +// Deprecated: switch to graphql/handler.New +func CacheSize(size int) Option { + return func(cfg *Config) { + cfg.cacheSize = size + } +} + +// UploadMaxSize sets the maximum number of bytes used to parse a request body +// as multipart/form-data. +// Deprecated: switch to graphql/handler.New +func UploadMaxSize(size int64) Option { + return func(cfg *Config) { + cfg.uploadMaxSize = size + } +} + +// UploadMaxMemory sets the maximum number of bytes used to parse a request body +// as multipart/form-data in memory, with the remainder stored on disk in +// temporary files. +// Deprecated: switch to graphql/handler.New +func UploadMaxMemory(size int64) Option { + return func(cfg *Config) { + cfg.uploadMaxMemory = size + } +} + +// WebsocketKeepAliveDuration allows you to reconfigure the keepalive behavior. +// By default, keepalive is enabled with a DefaultConnectionKeepAlivePingInterval +// duration. Set handler.connectionKeepAlivePingInterval = 0 to disable keepalive +// altogether. +// Deprecated: switch to graphql/handler.New +func WebsocketKeepAliveDuration(duration time.Duration) Option { + return func(cfg *Config) { + cfg.connectionKeepAlivePingInterval = duration + } +} + +// Add cache that will hold queries for automatic persisted queries (APQ) +// Deprecated: switch to graphql/handler.New +func EnablePersistedQueryCache(cache PersistedQueryCache) Option { + return func(cfg *Config) { + cfg.apqCache = cache + } +} + +func GetInitPayload(ctx context.Context) transport.InitPayload { + return transport.GetInitPayload(ctx) +} + +type apqAdapter struct { + PersistedQueryCache +} + +func (a apqAdapter) Get(key string) (value interface{}, ok bool) { + return a.PersistedQueryCache.Get(context.Background(), key) +} +func (a apqAdapter) Add(key string, value interface{}) { + a.PersistedQueryCache.Add(context.Background(), key, value.(string)) +} + +type PersistedQueryCache interface { + Add(ctx context.Context, hash string, query string) + Get(ctx context.Context, hash string) (string, bool) +} + +// Deprecated: use playground.Handler instead +func Playground(title string, endpoint string) http.HandlerFunc { + return playground.Handler(title, endpoint) +} + +// Deprecated: use transport.InitPayload instead +type InitPayload = transport.InitPayload diff --git a/handler/mock.go b/handler/mock.go deleted file mode 100644 index a3d73bd1902..00000000000 --- a/handler/mock.go +++ /dev/null @@ -1,61 +0,0 @@ -package handler - -import ( - "context" - - "github.com/99designs/gqlgen/graphql" - "github.com/vektah/gqlparser" - "github.com/vektah/gqlparser/ast" -) - -type executableSchemaMock struct { - QueryFunc func(ctx context.Context, op *ast.OperationDefinition) *graphql.Response - MutationFunc func(ctx context.Context, op *ast.OperationDefinition) *graphql.Response -} - -var _ graphql.ExecutableSchema = &executableSchemaMock{} - -func (e *executableSchemaMock) Schema() *ast.Schema { - return gqlparser.MustLoadSchema(&ast.Source{Input: ` - schema { query: Query, mutation: Mutation } - type Query { - empty: String! - } - scalar Upload - type File { - id: Int! - } - input UploadFile { - id: Int! - file: Upload! - } - type Mutation { - singleUpload(file: Upload!): File! - singleUploadWithPayload(req: UploadFile!): File! - multipleUpload(files: [Upload!]!): [File!]! - multipleUploadWithPayload(req: [UploadFile!]!): [File!]! - } - `}) -} - -func (e *executableSchemaMock) Complexity(typeName, field string, childComplexity int, args map[string]interface{}) (int, bool) { - return 0, false -} - -func (e *executableSchemaMock) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - if e.QueryFunc == nil { - return graphql.ErrorResponse(ctx, "queries are not supported") - } - return e.QueryFunc(ctx, op) -} - -func (e *executableSchemaMock) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return e.MutationFunc(ctx, op) -} - -func (e *executableSchemaMock) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return func() *graphql.Response { - <-ctx.Done() - return nil - } -} diff --git a/handler/stub.go b/handler/stub.go deleted file mode 100644 index d237e188921..00000000000 --- a/handler/stub.go +++ /dev/null @@ -1,51 +0,0 @@ -package handler - -import ( - "context" - - "github.com/99designs/gqlgen/graphql" - "github.com/vektah/gqlparser" - "github.com/vektah/gqlparser/ast" -) - -type executableSchemaStub struct { - NextResp chan struct{} -} - -var _ graphql.ExecutableSchema = &executableSchemaStub{} - -func (e *executableSchemaStub) Schema() *ast.Schema { - return gqlparser.MustLoadSchema(&ast.Source{Input: ` - schema { query: Query } - type Query { - me: User! - user(id: Int): User! - } - type User { name: String! } - `}) -} - -func (e *executableSchemaStub) Complexity(typeName, field string, childComplexity int, args map[string]interface{}) (int, bool) { - return 0, false -} - -func (e *executableSchemaStub) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return &graphql.Response{Data: []byte(`{"name":"test"}`)} -} - -func (e *executableSchemaStub) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} - -func (e *executableSchemaStub) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return func() *graphql.Response { - select { - case <-ctx.Done(): - return nil - case <-e.NextResp: - return &graphql.Response{ - Data: []byte(`{"name":"test"}`), - } - } - } -} diff --git a/handler/websocket_test.go b/handler/websocket_test.go deleted file mode 100644 index 44aa65e4f7a..00000000000 --- a/handler/websocket_test.go +++ /dev/null @@ -1,272 +0,0 @@ -package handler - -import ( - "context" - "encoding/json" - "errors" - "net/http/httptest" - "strings" - "testing" - "time" - - "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/graphql" - "github.com/gorilla/websocket" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/vektah/gqlparser/ast" -) - -func TestWebsocket(t *testing.T) { - next := make(chan struct{}) - h := GraphQL(&executableSchemaStub{next}) - - srv := httptest.NewServer(h) - defer srv.Close() - - t.Run("client must send valid json", func(t *testing.T) { - c := wsConnect(srv.URL) - defer c.Close() - - writeRaw(c, "hello") - - msg := readOp(c) - require.Equal(t, connectionErrorMsg, msg.Type) - require.Equal(t, `{"message":"invalid json"}`, string(msg.Payload)) - }) - - t.Run("client can terminate before init", func(t *testing.T) { - c := wsConnect(srv.URL) - defer c.Close() - - require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionTerminateMsg})) - - _, _, err := c.ReadMessage() - require.Equal(t, websocket.CloseNormalClosure, err.(*websocket.CloseError).Code) - }) - - t.Run("client must send init first", func(t *testing.T) { - c := wsConnect(srv.URL) - defer c.Close() - - require.NoError(t, c.WriteJSON(&operationMessage{Type: startMsg})) - - msg := readOp(c) - require.Equal(t, connectionErrorMsg, msg.Type) - require.Equal(t, `{"message":"unexpected message start"}`, string(msg.Payload)) - }) - - t.Run("server acks init", func(t *testing.T) { - c := wsConnect(srv.URL) - defer c.Close() - - require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) - - require.Equal(t, connectionAckMsg, readOp(c).Type) - require.Equal(t, connectionKeepAliveMsg, readOp(c).Type) - }) - - t.Run("client can terminate before run", func(t *testing.T) { - c := wsConnect(srv.URL) - defer c.Close() - - require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) - require.Equal(t, connectionAckMsg, readOp(c).Type) - require.Equal(t, connectionKeepAliveMsg, readOp(c).Type) - - require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionTerminateMsg})) - - _, _, err := c.ReadMessage() - require.Equal(t, websocket.CloseNormalClosure, err.(*websocket.CloseError).Code) - }) - - t.Run("client gets parse errors", func(t *testing.T) { - c := wsConnect(srv.URL) - defer c.Close() - - require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) - require.Equal(t, connectionAckMsg, readOp(c).Type) - require.Equal(t, connectionKeepAliveMsg, readOp(c).Type) - - require.NoError(t, c.WriteJSON(&operationMessage{ - Type: startMsg, - ID: "test_1", - Payload: json.RawMessage(`{"query": "!"}`), - })) - - msg := readOp(c) - require.Equal(t, errorMsg, msg.Type) - require.Equal(t, `[{"message":"Unexpected !","locations":[{"line":1,"column":1}]}]`, string(msg.Payload)) - }) - - t.Run("client can receive data", func(t *testing.T) { - c := wsConnect(srv.URL) - defer c.Close() - - require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) - require.Equal(t, connectionAckMsg, readOp(c).Type) - require.Equal(t, connectionKeepAliveMsg, readOp(c).Type) - - require.NoError(t, c.WriteJSON(&operationMessage{ - Type: startMsg, - ID: "test_1", - Payload: json.RawMessage(`{"query": "subscription { user { title } }"}`), - })) - - next <- struct{}{} - msg := readOp(c) - require.Equal(t, dataMsg, msg.Type) - require.Equal(t, "test_1", msg.ID) - require.Equal(t, `{"data":{"name":"test"}}`, string(msg.Payload)) - - next <- struct{}{} - msg = readOp(c) - require.Equal(t, dataMsg, msg.Type) - require.Equal(t, "test_1", msg.ID) - require.Equal(t, `{"data":{"name":"test"}}`, string(msg.Payload)) - - require.NoError(t, c.WriteJSON(&operationMessage{Type: stopMsg, ID: "test_1"})) - - msg = readOp(c) - require.Equal(t, completeMsg, msg.Type) - require.Equal(t, "test_1", msg.ID) - }) -} - -func TestWebsocketWithKeepAlive(t *testing.T) { - next := make(chan struct{}) - h := GraphQL(&executableSchemaStub{next}, WebsocketKeepAliveDuration(10*time.Millisecond)) - - srv := httptest.NewServer(h) - defer srv.Close() - - t.Run("client must receive keepalive", func(t *testing.T) { - c := wsConnect(srv.URL) - defer c.Close() - - require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) - require.Equal(t, connectionAckMsg, readOp(c).Type) - require.Equal(t, connectionKeepAliveMsg, readOp(c).Type) - - require.NoError(t, c.WriteJSON(&operationMessage{ - Type: startMsg, - ID: "test_1", - Payload: json.RawMessage(`{"query": "subscription { user { title } }"}`), - })) - - // keepalive - msg := readOp(c) - require.Equal(t, connectionKeepAliveMsg, msg.Type) - - // server message - next <- struct{}{} - msg = readOp(c) - require.Equal(t, dataMsg, msg.Type) - - // keepalive - msg = readOp(c) - require.Equal(t, connectionKeepAliveMsg, msg.Type) - }) -} - -func TestWebsocketInitFunc(t *testing.T) { - next := make(chan struct{}) - - t.Run("accept connection if WebsocketInitFunc is NOT provided", func(t *testing.T) { - h := GraphQL(&executableSchemaStub{next}) - srv := httptest.NewServer(h) - defer srv.Close() - - c := wsConnect(srv.URL) - defer c.Close() - - require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) - - require.Equal(t, connectionAckMsg, readOp(c).Type) - require.Equal(t, connectionKeepAliveMsg, readOp(c).Type) - }) - - t.Run("can return context for request from WebsocketInitFunc", func(t *testing.T) { - es := &executableSchemaMock{ - QueryFunc: func(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - assert.Equal(t, "newvalue", ctx.Value("newkey")) - return &graphql.Response{Data: []byte(`{"empty":"ok"}`)} - }, - } - - h := GraphQL(es, - WebsocketInitFunc(func(ctx context.Context, initPayload InitPayload) (context.Context, error) { - return context.WithValue(ctx, "newkey", "newvalue"), nil - })) - - c := client.New(h) - - socket := c.Websocket("{ empty } ") - defer socket.Close() - var resp struct { - Empty string - } - err := socket.Next(&resp) - require.NoError(t, err) - require.Equal(t, "ok", resp.Empty) - }) - - t.Run("accept connection if WebsocketInitFunc is provided and is accepting connection", func(t *testing.T) { - h := GraphQL(&executableSchemaStub{next}, - WebsocketInitFunc(func(ctx context.Context, initPayload InitPayload) (context.Context, error) { - return context.WithValue(ctx, "newkey", "newvalue"), nil - }), - ) - srv := httptest.NewServer(h) - defer srv.Close() - - c := wsConnect(srv.URL) - defer c.Close() - - require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) - - require.Equal(t, connectionAckMsg, readOp(c).Type) - require.Equal(t, connectionKeepAliveMsg, readOp(c).Type) - }) - - t.Run("reject connection if WebsocketInitFunc is provided and is accepting connection", func(t *testing.T) { - h := GraphQL(&executableSchemaStub{next}, WebsocketInitFunc(func(ctx context.Context, initPayload InitPayload) (context.Context, error) { - return ctx, errors.New("invalid init payload") - })) - srv := httptest.NewServer(h) - defer srv.Close() - - c := wsConnect(srv.URL) - defer c.Close() - - require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) - - msg := readOp(c) - require.Equal(t, connectionErrorMsg, msg.Type) - require.Equal(t, `{"message":"invalid init payload"}`, string(msg.Payload)) - }) -} - -func wsConnect(url string) *websocket.Conn { - c, resp, err := websocket.DefaultDialer.Dial(strings.Replace(url, "http://", "ws://", -1), nil) - if err != nil { - panic(err) - } - _ = resp.Body.Close() - - return c -} - -func writeRaw(conn *websocket.Conn, msg string) { - if err := conn.WriteMessage(websocket.TextMessage, []byte(msg)); err != nil { - panic(err) - } -} - -func readOp(conn *websocket.Conn) operationMessage { - var msg operationMessage - if err := conn.ReadJSON(&msg); err != nil { - panic(err) - } - return msg -} diff --git a/integration/generated.go b/integration/generated.go index c1386c304ee..3b69f28bd89 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -206,33 +206,34 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + data := ec._Query(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} + return &graphql.Response{ + Data: buf.Bytes(), + } + } -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } } type executionContext struct { - *graphql.RequestContext + *graphql.OperationContext *executableSchema } @@ -416,22 +417,20 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** func (ec *executionContext) _Element_child(ctx context.Context, field graphql.CollectedField, obj *models.Element) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Element", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Element().Child(rctx, obj) @@ -441,34 +440,31 @@ func (ec *executionContext) _Element_child(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*models.Element) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNElement2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx, field.Selections, res) } func (ec *executionContext) _Element_error(ctx context.Context, field graphql.CollectedField, obj *models.Element) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Element", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Element().Error(rctx, obj) @@ -478,34 +474,31 @@ func (ec *executionContext) _Element_error(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Element_mismatched(ctx context.Context, field graphql.CollectedField, obj *models.Element) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Element", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Element().Mismatched(rctx, obj) @@ -518,28 +511,25 @@ func (ec *executionContext) _Element_mismatched(ctx context.Context, field graph return graphql.Null } res := resTmp.([]bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOBoolean2ᚕboolᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_path(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Path(rctx) @@ -552,35 +542,32 @@ func (ec *executionContext) _Query_path(ctx context.Context, field graphql.Colle return graphql.Null } res := resTmp.([]*models.Element) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOElement2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx, field.Selections, res) } func (ec *executionContext) _Query_date(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_date_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Date(rctx, args["filter"].(models.DateFilter)) @@ -590,34 +577,31 @@ func (ec *executionContext) _Query_date(ctx context.Context, field graphql.Colle return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Viewer(rctx) @@ -630,28 +614,25 @@ func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*models.Viewer) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOViewer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐViewer(ctx, field.Selections, res) } func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().JSONEncoding(rctx) @@ -661,41 +642,38 @@ func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graph return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Query_error(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_error_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Error(rctx, args["type"].(*models.ErrorType)) @@ -705,41 +683,38 @@ func (ec *executionContext) _Query_error(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Query_complexity(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_complexity_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Complexity(rctx, args["value"].(int)) @@ -749,41 +724,38 @@ func (ec *executionContext) _Query_complexity(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) @@ -796,28 +768,25 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() @@ -830,28 +799,25 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return graphql.Null } res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -861,34 +827,31 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_likes(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.User().Likes(rctx, obj) @@ -898,34 +861,31 @@ func (ec *executionContext) _User_likes(ctx context.Context, field graphql.Colle return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.CollectedField, obj *models.Viewer) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "Viewer", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.User, nil @@ -938,28 +898,25 @@ func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*remote_api.User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋremote_apiᚐUser(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -969,34 +926,31 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1009,28 +963,25 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil @@ -1040,34 +991,31 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -1077,34 +1025,31 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1114,34 +1059,31 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1154,28 +1096,25 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -1185,34 +1124,31 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1225,28 +1161,25 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1256,34 +1189,31 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1296,28 +1226,25 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil @@ -1327,34 +1254,31 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1364,34 +1288,31 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil @@ -1401,34 +1322,31 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil @@ -1441,28 +1359,25 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil @@ -1472,34 +1387,31 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil @@ -1512,28 +1424,25 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil @@ -1543,34 +1452,31 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil @@ -1583,28 +1489,25 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil @@ -1614,34 +1517,31 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil @@ -1651,34 +1551,31 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil @@ -1691,28 +1588,25 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil @@ -1725,28 +1619,25 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil @@ -1756,34 +1647,31 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil @@ -1793,34 +1681,31 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { - if !ec.HasError(rctx) { + if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil @@ -1833,28 +1718,25 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return graphql.Null } res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil @@ -1867,35 +1749,32 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return graphql.Null } res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil @@ -1908,28 +1787,25 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil @@ -1942,28 +1818,25 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil @@ -1976,35 +1849,32 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return graphql.Null } res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil @@ -2017,28 +1887,25 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq return graphql.Null } res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil @@ -2051,28 +1918,25 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return graphql.Null } res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } - ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + + ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil @@ -2085,8 +1949,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return graphql.Null } res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + fc.Result = res return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } @@ -2142,7 +2005,7 @@ func (ec *executionContext) unmarshalInputDateFilter(ctx context.Context, obj in var elementImplementors = []string{"Element"} func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, obj *models.Element) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, elementImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, elementImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2203,9 +2066,9 @@ func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, queryImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) @@ -2311,7 +2174,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *remote_api.User) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, userImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2352,7 +2215,7 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj var viewerImplementors = []string{"Viewer"} func (ec *executionContext) _Viewer(ctx context.Context, sel ast.SelectionSet, obj *models.Viewer) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, viewerImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, viewerImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2376,7 +2239,7 @@ func (ec *executionContext) _Viewer(ctx context.Context, sel ast.SelectionSet, o var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2415,7 +2278,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2451,7 +2314,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __FieldImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2497,7 +2360,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __InputValueImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2533,7 +2396,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __SchemaImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2574,7 +2437,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.RequestContext, sel, __TypeImplementors) + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 @@ -2625,7 +2488,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2642,7 +2505,7 @@ func (ec *executionContext) marshalNElement2githubᚗcomᚋ99designsᚋgqlgenᚋ func (ec *executionContext) marshalNElement2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v *models.Element) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2657,7 +2520,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalInt(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2671,7 +2534,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2720,11 +2583,11 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2755,7 +2618,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -2791,11 +2654,11 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2840,11 +2703,11 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2881,11 +2744,11 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -2911,7 +2774,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null @@ -2926,7 +2789,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { - if !ec.HasError(graphql.GetResolverContext(ctx)) { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } @@ -3028,11 +2891,11 @@ func (ec *executionContext) marshalOElement2ᚕᚖgithubᚗcomᚋ99designsᚋgql } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3167,11 +3030,11 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3207,11 +3070,11 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3247,11 +3110,11 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { @@ -3302,11 +3165,11 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } for i := range v { i := i - rctx := &graphql.ResolverContext{ + fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } - ctx := graphql.WithResolverContext(ctx, rctx) + ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { diff --git a/integration/server/server.go b/integration/server/server.go index 63e31b96e45..63f2eca37d0 100644 --- a/integration/server/server.go +++ b/integration/server/server.go @@ -6,8 +6,11 @@ import ( "net/http" "os" + "github.com/99designs/gqlgen/graphql/handler/extension" + "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/handler" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/playground" "github.com/99designs/gqlgen/integration" "github.com/pkg/errors" "github.com/vektah/gqlparser/gqlerror" @@ -27,20 +30,21 @@ func main() { // function is executed. return value } - http.Handle("/", handler.Playground("GraphQL playground", "/query")) - http.Handle("/query", handler.GraphQL( - integration.NewExecutableSchema(cfg), - handler.ErrorPresenter(func(ctx context.Context, e error) *gqlerror.Error { - if e, ok := errors.Cause(e).(*integration.CustomError); ok { - return &gqlerror.Error{ - Message: e.UserMessage, - Path: graphql.GetResolverContext(ctx).Path(), - } + + srv := handler.NewDefaultServer(integration.NewExecutableSchema(cfg)) + srv.SetErrorPresenter(func(ctx context.Context, e error) *gqlerror.Error { + if e, ok := errors.Cause(e).(*integration.CustomError); ok { + return &gqlerror.Error{ + Message: e.UserMessage, + Path: graphql.GetFieldContext(ctx).Path(), } - return graphql.DefaultErrorPresenter(ctx, e) - }), - handler.ComplexityLimit(1000), - )) + } + return graphql.DefaultErrorPresenter(ctx, e) + }) + srv.Use(extension.FixedComplexityLimit(1000)) + + http.Handle("/", playground.Handler("GraphQL playground", "/query")) + http.Handle("/query", srv) log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, nil)) diff --git a/plugin/resolvergen/resolver.gotpl b/plugin/resolvergen/resolver.gotpl index 66d6efac25e..ab420050065 100644 --- a/plugin/resolvergen/resolver.gotpl +++ b/plugin/resolvergen/resolver.gotpl @@ -9,7 +9,6 @@ {{ reserveImport "errors" }} {{ reserveImport "bytes" }} -{{ reserveImport "github.com/99designs/gqlgen/handler" }} {{ reserveImport "github.com/vektah/gqlparser" }} {{ reserveImport "github.com/vektah/gqlparser/ast" }} {{ reserveImport "github.com/99designs/gqlgen/graphql" }} diff --git a/plugin/servergen/server.gotpl b/plugin/servergen/server.gotpl index fca71c53cda..85ec87fdbcf 100644 --- a/plugin/servergen/server.gotpl +++ b/plugin/servergen/server.gotpl @@ -2,7 +2,7 @@ {{ reserveImport "log" }} {{ reserveImport "net/http" }} {{ reserveImport "os" }} -{{ reserveImport "github.com/99designs/gqlgen/handler" }} +{{ reserveImport "github.com/99designs/gqlgen/graphql/handler" }} const defaultPort = "8080" @@ -12,8 +12,10 @@ func main() { port = defaultPort } + srv := handler.NewDefaultServer({{ lookupImport .ExecPackageName }}.NewExecutableSchema({{ lookupImport .ExecPackageName}}.Config{Resolvers: &{{ lookupImport .ResolverPackageName}}.Resolver{}})) + http.Handle("/", handler.Playground("GraphQL playground", "/query")) - http.Handle("/query", handler.GraphQL({{ lookupImport .ExecPackageName }}.NewExecutableSchema({{ lookupImport .ExecPackageName}}.Config{Resolvers: &{{ lookupImport .ResolverPackageName}}.Resolver{}}))) + http.Handle("/query", srv) log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":" + port, nil)) diff --git a/plugin/stubgen/stubs.gotpl b/plugin/stubgen/stubs.gotpl index c1e9b313149..63df84767ce 100644 --- a/plugin/stubgen/stubs.gotpl +++ b/plugin/stubgen/stubs.gotpl @@ -7,7 +7,6 @@ {{ reserveImport "errors" }} {{ reserveImport "bytes" }} -{{ reserveImport "github.com/99designs/gqlgen/handler" }} {{ reserveImport "github.com/vektah/gqlparser" }} {{ reserveImport "github.com/vektah/gqlparser/ast" }} {{ reserveImport "github.com/99designs/gqlgen/graphql" }} diff --git a/testdata/gqlgen.go b/testdata/gqlgen.go index f4bbe75507d..e22451c6f98 100644 --- a/testdata/gqlgen.go +++ b/testdata/gqlgen.go @@ -8,6 +8,8 @@ import ( "os" "time" + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/api" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/plugin/stubgen" @@ -19,7 +21,7 @@ func main() { log.SetOutput(ioutil.Discard) - start := time.Now() + start := graphql.Now() cfg, err := config.LoadConfigFromDefaultLocations() if err != nil {