From faf0416bf719ea00f40a96a061567807cef16827 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 25 Sep 2018 11:41:57 +1000 Subject: [PATCH] Parent resolver generated contexts --- codegen/object.go | 2 +- codegen/templates/data.go | 2 +- codegen/templates/field.gotpl | 4 +- codegen/testserver/generated.go | 423 ++++++++++++++++++++++----- codegen/testserver/generated_test.go | 63 +++- codegen/testserver/gqlgen.yml | 3 + codegen/testserver/models-gen.go | 5 + codegen/testserver/resolver.go | 12 + codegen/testserver/schema.graphql | 6 + example/chat/generated.go | 133 ++++++--- example/config/generated.go | 135 ++++++--- example/dataloader/generated.go | 159 ++++++---- example/scalars/generated.go | 146 +++++---- example/selection/generated.go | 131 ++++++--- example/starwars/generated.go | 248 ++++++++++------ example/todo/generated.go | 136 ++++++--- integration/generated.go | 153 ++++++---- 17 files changed, 1250 insertions(+), 511 deletions(-) diff --git a/codegen/object.go b/codegen/object.go index d9f610f4591..0c9479b0ae5 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -203,7 +203,7 @@ func (f *Field) CallArgs() string { var args []string if f.IsResolver() { - args = append(args, "ctx") + args = append(args, "rctx") if !f.Object.Root { args = append(args, "obj") diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 88c45431edf..5a15e9109b6 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -2,7 +2,7 @@ package templates var data = map[string]string{ "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", - "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t{{- end }}\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tArgs: {{if $field.Args }}args{{else}}nil{{end}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(ctx context.Context) (interface{}, error) {\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\t{{ $field.WriteJson }}\n\t}\n{{ end }}\n", + "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\trctx := ctx // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t{{- end }}\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tArgs: {{if $field.Args }}args{{else}}nil{{end}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\t{{ $field.WriteJson }}\n\t}\n{{ end }}\n", "generated.gotpl": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage {{ .PackageName }}\n\nimport (\n{{- range $import := .Imports }}\n\t{{- $import.Write }}\n{{ end }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc {{ $field.ArgsFunc }}(rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc {{ $directive.ArgsFunc }}(rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := {{ $directive.ArgsFunc }}(rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() *introspection.Schema {\n\treturn introspection.WrapSchema(parsedSchema)\n}\n\nfunc (ec *executionContext) introspectType(name string) *introspection.Type {\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name])\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t&ast.Source{Name: {{.SchemaFilename|quote}}, Input: {{.SchemaRaw|rawQuote}}},\n)\n", "input.gotpl": "\t{{- if .IsMarshaled }}\n\tfunc Unmarshal{{ .GQLType }}(v interface{}) ({{.FullName}}, error) {\n\t\tvar it {{.FullName}}\n\t\tvar asMap = v.(map[string]interface{})\n\t\t{{ range $field := .Fields}}\n\t\t\t{{- if $field.Default}}\n\t\t\t\tif _, present := asMap[{{$field.GQLName|quote}}] ; !present {\n\t\t\t\t\tasMap[{{$field.GQLName|quote}}] = {{ $field.Default | dump }}\n\t\t\t\t}\n\t\t\t{{- end}}\n\t\t{{- end }}\n\n\t\tfor k, v := range asMap {\n\t\t\tswitch k {\n\t\t\t{{- range $field := .Fields }}\n\t\t\tcase {{$field.GQLName|quote}}:\n\t\t\t\tvar err error\n\t\t\t\t{{ $field.Unmarshal (print \"it.\" $field.GoFieldName) \"v\" }}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn it, err\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\t}\n\t\t}\n\n\t\treturn it, nil\n\t}\n\t{{- end }}\n", "interface.gotpl": "{{- $interface := . }}\n\nfunc (ec *executionContext) _{{$interface.GQLType}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.FullName}}) graphql.Marshaler {\n\tswitch obj := (*obj).(type) {\n\tcase nil:\n\t\treturn graphql.Null\n\t{{- range $implementor := $interface.Implementors }}\n\t\t{{- if $implementor.ValueReceiver }}\n\t\t\tcase {{$implementor.FullName}}:\n\t\t\t\treturn ec._{{$implementor.GQLType}}(ctx, sel, &obj)\n\t\t{{- end}}\n\t\tcase *{{$implementor.FullName}}:\n\t\t\treturn ec._{{$implementor.GQLType}}(ctx, sel, obj)\n\t{{- end }}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"unexpected type %T\", obj))\n\t}\n}\n", diff --git a/codegen/templates/field.gotpl b/codegen/templates/field.gotpl index b33f2123794..56943d2f7ae 100644 --- a/codegen/templates/field.gotpl +++ b/codegen/templates/field.gotpl @@ -14,6 +14,7 @@ ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, }) + rctx := ctx // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 results, err := ec.resolvers.{{ $field.ShortInvocation }} if err != nil { ec.Error(ctx, err) @@ -46,7 +47,8 @@ Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children {{- if $field.IsResolver }} return ec.resolvers.{{ $field.ShortInvocation }} {{- else if $field.IsMethod }} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 2c64cd9f4a3..61547ebb1cb 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -36,6 +36,7 @@ type ResolverRoot interface { ForcedResolver() ForcedResolverResolver Query() QueryResolver Subscription() SubscriptionResolver + User() UserResolver } type DirectiveRoot struct { @@ -85,6 +86,7 @@ type ComplexityRoot struct { Shapes func(childComplexity int) int ErrorBubble func(childComplexity int) int Valid func(childComplexity int) int + User func(childComplexity int, id int) int KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) int } @@ -98,6 +100,11 @@ type ComplexityRoot struct { Updated func(childComplexity int) int InitPayload func(childComplexity int) int } + + User struct { + Id func(childComplexity int) int + Friends func(childComplexity int) int + } } type ForcedResolverResolver interface { @@ -114,12 +121,16 @@ type QueryResolver interface { Shapes(ctx context.Context) ([]*Shape, error) ErrorBubble(ctx context.Context) (*Error, error) Valid(ctx context.Context) (string, error) + User(ctx context.Context, id int) (User, error) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) } type SubscriptionResolver interface { Updated(ctx context.Context) (<-chan string, error) InitPayload(ctx context.Context) (<-chan string, error) } +type UserResolver interface { + Friends(ctx context.Context, obj *User) ([]User, error) +} func field_Query_mapInput_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} @@ -222,6 +233,21 @@ func field_Query_keywords_args(rawArgs map[string]interface{}) (map[string]inter } +func field_Query_user_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil + +} + func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} var arg0 string @@ -678,6 +704,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Valid(childComplexity), true + case "Query.user": + if e.complexity.Query.User == nil { + break + } + + args, err := field_Query_user_args(rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.User(childComplexity, args["id"].(int)), true + case "Query.keywordArgs": if e.complexity.Query.KeywordArgs == nil { break @@ -725,6 +763,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Subscription.InitPayload(childComplexity), true + case "User.id": + if e.complexity.User.Id == nil { + break + } + + return e.complexity.User.Id(childComplexity), true + + case "User.friends": + if e.complexity.User.Friends == nil { + break + } + + return e.complexity.User.Friends(childComplexity), true + } return 0, false } @@ -824,7 +876,8 @@ func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Radius, nil }) if resTmp == nil { @@ -843,7 +896,8 @@ func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Area(), nil }) if resTmp == nil { @@ -904,7 +958,8 @@ func (ec *executionContext) _Error_id(ctx context.Context, field graphql.Collect Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -926,7 +981,8 @@ func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.ErrorOnNonRequiredField() }) if resTmp == nil { @@ -945,7 +1001,8 @@ func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, fie Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -967,7 +1024,8 @@ func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1028,8 +1086,9 @@ func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.ForcedResolver().Field(ctx, obj) + 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) }) if resTmp == nil { return graphql.Null @@ -1082,7 +1141,8 @@ func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1134,7 +1194,8 @@ func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1186,7 +1247,8 @@ func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedF Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1238,7 +1300,8 @@ func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1338,6 +1401,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } wg.Done() }(i, field) + case "user": + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_user(ctx, field) + if out.Values[i] == graphql.Null { + invalid = true + } + wg.Done() + }(i, field) case "keywordArgs": wg.Add(1) go func(i int, field graphql.CollectedField) { @@ -1370,8 +1442,9 @@ func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().InvalidIdentifier(ctx) + 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) }) if resTmp == nil { return graphql.Null @@ -1394,8 +1467,9 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Collision(ctx) + 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) }) if resTmp == nil { return graphql.Null @@ -1424,8 +1498,9 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().MapInput(ctx, args["input"].(*map[string]interface{})) + 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{})) }) if resTmp == nil { return graphql.Null @@ -1453,8 +1528,9 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Recursive(ctx, args["input"].(*RecursiveInputSlice)) + 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)) }) if resTmp == nil { return graphql.Null @@ -1482,8 +1558,9 @@ func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().NestedInputs(ctx, args["input"].([][]*OuterInput)) + 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)) }) if resTmp == nil { return graphql.Null @@ -1505,8 +1582,9 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().NestedOutputs(ctx) + 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) }) if resTmp == nil { return graphql.Null @@ -1598,8 +1676,9 @@ func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Keywords(ctx, args["input"].(*Keywords)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Keywords(rctx, args["input"].(*Keywords)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1620,8 +1699,9 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Shapes(ctx) + 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) }) if resTmp == nil { return graphql.Null @@ -1676,8 +1756,9 @@ func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().ErrorBubble(ctx) + 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) }) if resTmp == nil { return graphql.Null @@ -1700,8 +1781,9 @@ func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Valid(ctx) + 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) { @@ -1714,6 +1796,36 @@ func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.Coll return graphql.MarshalString(res) } +// nolint: vetshadow +func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + rawArgs := field.ArgumentMap(ec.Variables) + args, err := field_Query_user_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + 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) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(User) + rctx.Result = res + + return ec._User(ctx, field.Selections, &res) +} + // nolint: vetshadow func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) @@ -1728,8 +1840,9 @@ func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().KeywordArgs(ctx, args["break"].(string), args["default"].(string), args["func"].(string), args["interface"].(string), args["select"].(string), args["case"].(string), args["defer"].(string), args["go"].(string), args["map"].(string), args["struct"].(string), args["chan"].(string), args["else"].(string), args["goto"].(string), args["package"].(string), args["switch"].(string), args["const"].(string), args["fallthrough"].(string), args["if"].(string), args["range"].(string), args["type"].(string), args["continue"].(string), args["for"].(string), args["import"].(string), args["return"].(string), args["var"].(string)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().KeywordArgs(rctx, args["break"].(string), args["default"].(string), args["func"].(string), args["interface"].(string), args["select"].(string), args["case"].(string), args["defer"].(string), args["go"].(string), args["map"].(string), args["struct"].(string), args["chan"].(string), args["else"].(string), args["goto"].(string), args["package"].(string), args["switch"].(string), args["const"].(string), args["fallthrough"].(string), args["if"].(string), args["range"].(string), args["type"].(string), args["continue"].(string), args["for"].(string), args["import"].(string), args["return"].(string), args["var"].(string)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1756,7 +1869,8 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + 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)), nil }) if resTmp == nil { @@ -1780,7 +1894,8 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return ec.introspectSchema(), nil }) if resTmp == nil { @@ -1835,7 +1950,8 @@ func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Length, nil }) if resTmp == nil { @@ -1854,7 +1970,8 @@ func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Width, nil }) if resTmp == nil { @@ -1873,7 +1990,8 @@ func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Area(), nil }) if resTmp == nil { @@ -1911,7 +2029,8 @@ func (ec *executionContext) _Subscription_updated(ctx context.Context, field gra ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, }) - results, err := ec.resolvers.Subscription().Updated(ctx) + rctx := ctx // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 + results, err := ec.resolvers.Subscription().Updated(rctx) if err != nil { ec.Error(ctx, err) return nil @@ -1931,7 +2050,8 @@ func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, }) - results, err := ec.resolvers.Subscription().InitPayload(ctx) + rctx := ctx // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 + results, err := ec.resolvers.Subscription().InitPayload(rctx) if err != nil { ec.Error(ctx, err) return nil @@ -1947,6 +2067,125 @@ func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field } } +var userImplementors = []string{"User"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, userImplementors) + + var wg sync.WaitGroup + out := graphql.NewOrderedMap(len(fields)) + invalid := false + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "id": + out.Values[i] = ec._User_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "friends": + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._User_friends(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + wg.Done() + }(i, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + wg.Wait() + if invalid { + return graphql.Null + } + return out +} + +// nolint: vetshadow +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "User", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + 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) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + rctx.Result = res + return graphql.MarshalInt(res) +} + +// nolint: vetshadow +func (ec *executionContext) _User_friends(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "User", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + 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) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]User) + rctx.Result = res + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec._User(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 +} + var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst @@ -1997,7 +2236,8 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2019,7 +2259,8 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -2038,7 +2279,8 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2069,7 +2311,8 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2163,7 +2406,8 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2185,7 +2429,8 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -2204,7 +2449,8 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2226,7 +2472,8 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -2294,7 +2541,8 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2316,7 +2564,8 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -2335,7 +2584,8 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2390,7 +2640,8 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2420,7 +2671,8 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2442,7 +2694,8 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -2500,7 +2753,8 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2522,7 +2776,8 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -2541,7 +2796,8 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2571,7 +2827,8 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil }) if resTmp == nil { @@ -2638,7 +2895,8 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2693,7 +2951,8 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2723,7 +2982,8 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil }) if resTmp == nil { @@ -2747,7 +3007,8 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -2771,7 +3032,8 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2872,7 +3134,8 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2894,7 +3157,8 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2917,7 +3181,8 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if resTmp == nil { @@ -2942,7 +3207,8 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -2994,7 +3260,8 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil }) if resTmp == nil { @@ -3046,7 +3313,8 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -3104,7 +3372,8 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -3156,7 +3425,8 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil }) if resTmp == nil { @@ -3208,7 +3478,8 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.OfType(), nil }) if resTmp == nil { @@ -3512,6 +3783,7 @@ var parsedSchema = gqlparser.MustLoadSchema( shapes: [Shape] errorBubble: Error valid: String! + user(id: Int!): User! } type Subscription { @@ -3519,6 +3791,11 @@ type Subscription { initPayload: String! } +type User { + id: Int! + friends: [User!]! +} + type Error { id: ID! errorOnNonRequiredField: String diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index b9764fdc1a4..0d6e0c674ba 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -14,6 +14,8 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/client" @@ -34,10 +36,20 @@ func TestForcedResolverFieldIsPointer(t *testing.T) { } func TestGeneratedServer(t *testing.T) { - tickChan := make(chan string, 1) - srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{ - Resolvers: &testResolver{tick: tickChan}, - }))) + resolvers := &testResolver{tick: make(chan string, 1)} + + srv := httptest.NewServer( + 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))) + }), + )) c := client.New(srv.URL) t.Run("null bubbling", func(t *testing.T) { @@ -87,13 +99,36 @@ func TestGeneratedServer(t *testing.T) { }) + t.Run("middleware", func(t *testing.T) { + var resp struct { + User struct { + ID int + Friends []struct { + ID int + } + } + } + + called := false + resolvers.userFriends = func(ctx context.Context, obj *User) ([]User, error) { + assert.Equal(t, []int{1, 2, 1, 2}, ctx.Value("path")) + called = true + return []User{}, nil + } + + err := c.Post(`query { user(id: 1) { id, friends { id } } }`, &resp) + + require.NoError(t, err) + require.True(t, called) + }) + t.Run("subscriptions", func(t *testing.T) { t.Run("wont leak goroutines", func(t *testing.T) { initialGoroutineCount := runtime.NumGoroutine() sub := c.Websocket(`subscription { updated }`) - tickChan <- "message" + resolvers.tick <- "message" var msg struct { resp struct { @@ -162,12 +197,18 @@ func TestResponseExtension(t *testing.T) { } type testResolver struct { - tick chan string + tick chan string + userFriends func(ctx context.Context, obj *User) ([]User, error) } func (r *testResolver) ForcedResolver() ForcedResolverResolver { return &forcedResolverResolver{nil} } + +func (r *testResolver) User() UserResolver { + return &testUserResolver{r} +} + func (r *testResolver) Query() QueryResolver { return &testQueryResolver{} } @@ -182,10 +223,20 @@ func (r *testQueryResolver) Valid(ctx context.Context) (string, error) { return "Ok", nil } +func (r *testQueryResolver) User(ctx context.Context, id int) (User, error) { + return User{ID: 1}, nil +} + func (r *testResolver) Subscription() SubscriptionResolver { return &testSubscriptionResolver{r} } +type testUserResolver struct{ *testResolver } + +func (r *testResolver) Friends(ctx context.Context, obj *User) ([]User, error) { + return r.userFriends(ctx, obj) +} + type testSubscriptionResolver struct{ *testResolver } func (r *testSubscriptionResolver) Updated(ctx context.Context) (<-chan string, error) { diff --git a/codegen/testserver/gqlgen.yml b/codegen/testserver/gqlgen.yml index 6cea9a88938..943ae4ad3ca 100644 --- a/codegen/testserver/gqlgen.yml +++ b/codegen/testserver/gqlgen.yml @@ -29,5 +29,8 @@ models: model: "github.com/99designs/gqlgen/codegen/testserver.ForcedResolver" fields: field: { resolver: true } + User: + fields: + friends: { resolver: true } Error: model: "github.com/99designs/gqlgen/codegen/testserver.Error" diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index 6195a275be1..ea2208bbd41 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -45,3 +45,8 @@ type OuterInput struct { type OuterObject struct { Inner InnerObject `json:"inner"` } + +type User struct { + ID int `json:"id"` + Friends []User `json:"friends"` +} diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 167a0c2825a..4d4ca217fcd 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -20,6 +20,9 @@ func (r *Resolver) Query() QueryResolver { func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} } +func (r *Resolver) User() UserResolver { + return &userResolver{r} +} type forcedResolverResolver struct{ *Resolver } @@ -59,6 +62,9 @@ func (r *queryResolver) ErrorBubble(ctx context.Context) (*Error, error) { func (r *queryResolver) Valid(ctx context.Context) (string, error) { panic("not implemented") } +func (r *queryResolver) User(ctx context.Context, id int) (User, error) { + panic("not implemented") +} func (r *queryResolver) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) { panic("not implemented") } @@ -71,3 +77,9 @@ func (r *subscriptionResolver) Updated(ctx context.Context) (<-chan string, erro func (r *subscriptionResolver) InitPayload(ctx context.Context) (<-chan string, error) { panic("not implemented") } + +type userResolver struct{ *Resolver } + +func (r *userResolver) Friends(ctx context.Context, obj *User) ([]User, error) { + panic("not implemented") +} diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index d88aa2ee84f..56d66b11a81 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -9,6 +9,7 @@ type Query { shapes: [Shape] errorBubble: Error valid: String! + user(id: Int!): User! } type Subscription { @@ -16,6 +17,11 @@ type Subscription { initPayload: String! } +type User { + id: Int! + friends: [User!]! +} + type Error { id: ID! errorOnNonRequiredField: String diff --git a/example/chat/generated.go b/example/chat/generated.go index 3075b70daa1..33d96b52a4d 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -392,7 +392,8 @@ func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -414,7 +415,8 @@ func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Messages, nil }) if resTmp == nil { @@ -514,7 +516,8 @@ func (ec *executionContext) _Message_id(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -536,7 +539,8 @@ func (ec *executionContext) _Message_text(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -558,7 +562,8 @@ func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.CreatedBy, nil }) if resTmp == nil { @@ -580,7 +585,8 @@ func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.CreatedAt, nil }) if resTmp == nil { @@ -642,8 +648,9 @@ func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Mutation().Post(ctx, args["text"].(string), args["username"].(string), args["roomName"].(string)) + resTmp := ec.FieldMiddleware(ctx, nil, 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)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -711,8 +718,9 @@ func (ec *executionContext) _Query_room(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Room(ctx, args["name"].(string)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Room(rctx, args["name"].(string)) }) if resTmp == nil { return graphql.Null @@ -741,7 +749,8 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + 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)), nil }) if resTmp == nil { @@ -765,7 +774,8 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return ec.introspectSchema(), nil }) if resTmp == nil { @@ -812,7 +822,8 @@ func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, fiel ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, }) - results, err := ec.resolvers.Subscription().MessageAdded(ctx, args["roomName"].(string)) + rctx := ctx // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 + results, err := ec.resolvers.Subscription().MessageAdded(rctx, args["roomName"].(string)) if err != nil { ec.Error(ctx, err) return nil @@ -880,7 +891,8 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -902,7 +914,8 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -921,7 +934,8 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -952,7 +966,8 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1046,7 +1061,8 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1068,7 +1084,8 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1087,7 +1104,8 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1109,7 +1127,8 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1177,7 +1196,8 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1199,7 +1219,8 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1218,7 +1239,8 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1273,7 +1295,8 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1303,7 +1326,8 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1325,7 +1349,8 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1383,7 +1408,8 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1405,7 +1431,8 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1424,7 +1451,8 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1454,7 +1482,8 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil }) if resTmp == nil { @@ -1521,7 +1550,8 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1576,7 +1606,8 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1606,7 +1637,8 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil }) if resTmp == nil { @@ -1630,7 +1662,8 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1654,7 +1687,8 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1755,7 +1789,8 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1777,7 +1812,8 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1800,7 +1836,8 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if resTmp == nil { @@ -1825,7 +1862,8 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -1877,7 +1915,8 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil }) if resTmp == nil { @@ -1929,7 +1968,8 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -1987,7 +2027,8 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -2039,7 +2080,8 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil }) if resTmp == nil { @@ -2091,7 +2133,8 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.OfType(), nil }) if resTmp == nil { diff --git a/example/config/generated.go b/example/config/generated.go index 49724eae93f..f6e6d5cce90 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -306,8 +306,9 @@ func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Mutation().CreateTodo(ctx, args["input"].(NewTodo)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateTodo(rctx, args["input"].(NewTodo)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -372,8 +373,9 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Todos(ctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Todos(rctx) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -433,7 +435,8 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + 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)), nil }) if resTmp == nil { @@ -457,7 +460,8 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return ec.introspectSchema(), nil }) if resTmp == nil { @@ -536,8 +540,9 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Todo().ID(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Todo().ID(rctx, obj) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -558,7 +563,8 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DatabaseID, nil }) if resTmp == nil { @@ -580,7 +586,8 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -602,7 +609,8 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Done, nil }) if resTmp == nil { @@ -624,7 +632,8 @@ func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.User, nil }) if resTmp == nil { @@ -682,7 +691,8 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -704,7 +714,8 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.FullName(), nil }) if resTmp == nil { @@ -768,7 +779,8 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -790,7 +802,8 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -809,7 +822,8 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -840,7 +854,8 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -934,7 +949,8 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -956,7 +972,8 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -975,7 +992,8 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -997,7 +1015,8 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1065,7 +1084,8 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1087,7 +1107,8 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1106,7 +1127,8 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1161,7 +1183,8 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1191,7 +1214,8 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1213,7 +1237,8 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1271,7 +1296,8 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1293,7 +1319,8 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1312,7 +1339,8 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1342,7 +1370,8 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil }) if resTmp == nil { @@ -1409,7 +1438,8 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1464,7 +1494,8 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1494,7 +1525,8 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil }) if resTmp == nil { @@ -1518,7 +1550,8 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1542,7 +1575,8 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1643,7 +1677,8 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1665,7 +1700,8 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1688,7 +1724,8 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if resTmp == nil { @@ -1713,7 +1750,8 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -1765,7 +1803,8 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil }) if resTmp == nil { @@ -1817,7 +1856,8 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -1875,7 +1915,8 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -1927,7 +1968,8 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil }) if resTmp == nil { @@ -1979,7 +2021,8 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.OfType(), nil }) if resTmp == nil { diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index daa427e22f8..4ba9adab5ad 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -401,7 +401,8 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -423,7 +424,8 @@ func (ec *executionContext) _Address_street(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Street, nil }) if resTmp == nil { @@ -445,7 +447,8 @@ func (ec *executionContext) _Address_country(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Country, nil }) if resTmp == nil { @@ -515,7 +518,8 @@ func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -537,7 +541,8 @@ func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -559,8 +564,9 @@ func (ec *executionContext) _Customer_address(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Customer().Address(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Customer().Address(rctx, obj) }) if resTmp == nil { return graphql.Null @@ -583,8 +589,9 @@ func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Customer().Orders(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Customer().Orders(rctx, obj) }) if resTmp == nil { return graphql.Null @@ -665,7 +672,8 @@ func (ec *executionContext) _Item_name(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -734,7 +742,8 @@ func (ec *executionContext) _Order_id(ctx context.Context, field graphql.Collect Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -756,7 +765,8 @@ func (ec *executionContext) _Order_date(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Date, nil }) if resTmp == nil { @@ -778,7 +788,8 @@ func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Amount, nil }) if resTmp == nil { @@ -800,8 +811,9 @@ func (ec *executionContext) _Order_items(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Order().Items(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Order().Items(rctx, obj) }) if resTmp == nil { return graphql.Null @@ -904,8 +916,9 @@ func (ec *executionContext) _Query_customers(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Customers(ctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Customers(rctx) }) if resTmp == nil { return graphql.Null @@ -962,8 +975,9 @@ func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Torture1d(ctx, args["customerIds"].([]int)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Torture1d(rctx, args["customerIds"].([]int)) }) if resTmp == nil { return graphql.Null @@ -1020,8 +1034,9 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Torture2d(ctx, args["customerIds"].([][]int)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Torture2d(rctx, args["customerIds"].([][]int)) }) if resTmp == nil { return graphql.Null @@ -1109,7 +1124,8 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + 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)), nil }) if resTmp == nil { @@ -1133,7 +1149,8 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return ec.introspectSchema(), nil }) if resTmp == nil { @@ -1199,7 +1216,8 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1221,7 +1239,8 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1240,7 +1259,8 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1271,7 +1291,8 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1365,7 +1386,8 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1387,7 +1409,8 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1406,7 +1429,8 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1428,7 +1452,8 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1496,7 +1521,8 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1518,7 +1544,8 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1537,7 +1564,8 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1592,7 +1620,8 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1622,7 +1651,8 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1644,7 +1674,8 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1702,7 +1733,8 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1724,7 +1756,8 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1743,7 +1776,8 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1773,7 +1807,8 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil }) if resTmp == nil { @@ -1840,7 +1875,8 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1895,7 +1931,8 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1925,7 +1962,8 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil }) if resTmp == nil { @@ -1949,7 +1987,8 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1973,7 +2012,8 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2074,7 +2114,8 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2096,7 +2137,8 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2119,7 +2161,8 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if resTmp == nil { @@ -2144,7 +2187,8 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -2196,7 +2240,8 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil }) if resTmp == nil { @@ -2248,7 +2293,8 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -2306,7 +2352,8 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -2358,7 +2405,8 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil }) if resTmp == nil { @@ -2410,7 +2458,8 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.OfType(), nil }) if resTmp == nil { diff --git a/example/scalars/generated.go b/example/scalars/generated.go index d4392f4644a..6937f665716 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -327,7 +327,8 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -349,7 +350,8 @@ func (ec *executionContext) _Address_location(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Location, nil }) if resTmp == nil { @@ -427,8 +429,9 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().User(ctx, args["id"].(external.ObjectID)) + 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"].(external.ObjectID)) }) if resTmp == nil { return graphql.Null @@ -457,8 +460,9 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Search(ctx, args["input"].(model.SearchArgs)) + resTmp := ec.FieldMiddleware(ctx, nil, 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)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -518,7 +522,8 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + 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)), nil }) if resTmp == nil { @@ -542,7 +547,8 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return ec.introspectSchema(), nil }) if resTmp == nil { @@ -631,7 +637,8 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -653,7 +660,8 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -675,7 +683,8 @@ func (ec *executionContext) _User_created(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -694,7 +703,8 @@ func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.IsBanned, nil }) if resTmp == nil { @@ -716,8 +726,9 @@ func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field g Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.User().PrimitiveResolver(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().PrimitiveResolver(rctx, obj) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -738,8 +749,9 @@ func (ec *executionContext) _User_customResolver(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.User().CustomResolver(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().CustomResolver(rctx, obj) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -760,7 +772,8 @@ func (ec *executionContext) _User_address(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Address, nil }) if resTmp == nil { @@ -780,7 +793,8 @@ func (ec *executionContext) _User_tier(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Tier, nil }) if resTmp == nil { @@ -841,7 +855,8 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -863,7 +878,8 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -882,7 +898,8 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -913,7 +930,8 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1007,7 +1025,8 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1029,7 +1048,8 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1048,7 +1068,8 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1070,7 +1091,8 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1138,7 +1160,8 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1160,7 +1183,8 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1179,7 +1203,8 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1234,7 +1259,8 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1264,7 +1290,8 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1286,7 +1313,8 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1344,7 +1372,8 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1366,7 +1395,8 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1385,7 +1415,8 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1415,7 +1446,8 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil }) if resTmp == nil { @@ -1482,7 +1514,8 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1537,7 +1570,8 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1567,7 +1601,8 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil }) if resTmp == nil { @@ -1591,7 +1626,8 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1615,7 +1651,8 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1716,7 +1753,8 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1738,7 +1776,8 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1761,7 +1800,8 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if resTmp == nil { @@ -1786,7 +1826,8 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -1838,7 +1879,8 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil }) if resTmp == nil { @@ -1890,7 +1932,8 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -1948,7 +1991,8 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -2000,7 +2044,8 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil }) if resTmp == nil { @@ -2052,7 +2097,8 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.OfType(), nil }) if resTmp == nil { diff --git a/example/selection/generated.go b/example/selection/generated.go index bfe313dcfa4..7ce421db180 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -263,7 +263,8 @@ func (ec *executionContext) _Like_reaction(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Reaction, nil }) if resTmp == nil { @@ -285,7 +286,8 @@ func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Sent, nil }) if resTmp == nil { @@ -307,7 +309,8 @@ func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Selection, nil }) if resTmp == nil { @@ -335,7 +338,8 @@ func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Collected, nil }) if resTmp == nil { @@ -402,7 +406,8 @@ func (ec *executionContext) _Post_message(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Message, nil }) if resTmp == nil { @@ -424,7 +429,8 @@ func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Sent, nil }) if resTmp == nil { @@ -446,7 +452,8 @@ func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Selection, nil }) if resTmp == nil { @@ -474,7 +481,8 @@ func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Collected, nil }) if resTmp == nil { @@ -542,8 +550,9 @@ func (ec *executionContext) _Query_events(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Events(ctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Events(rctx) }) if resTmp == nil { return graphql.Null @@ -600,7 +609,8 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + 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)), nil }) if resTmp == nil { @@ -624,7 +634,8 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return ec.introspectSchema(), nil }) if resTmp == nil { @@ -690,7 +701,8 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -712,7 +724,8 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -731,7 +744,8 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -762,7 +776,8 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -856,7 +871,8 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -878,7 +894,8 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -897,7 +914,8 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -919,7 +937,8 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -987,7 +1006,8 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1009,7 +1029,8 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1028,7 +1049,8 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1083,7 +1105,8 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1113,7 +1136,8 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1135,7 +1159,8 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1193,7 +1218,8 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1215,7 +1241,8 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1234,7 +1261,8 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1264,7 +1292,8 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil }) if resTmp == nil { @@ -1331,7 +1360,8 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1386,7 +1416,8 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1416,7 +1447,8 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil }) if resTmp == nil { @@ -1440,7 +1472,8 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1464,7 +1497,8 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1565,7 +1599,8 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1587,7 +1622,8 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1610,7 +1646,8 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if resTmp == nil { @@ -1635,7 +1672,8 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -1687,7 +1725,8 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil }) if resTmp == nil { @@ -1739,7 +1778,8 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -1797,7 +1837,8 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -1849,7 +1890,8 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil }) if resTmp == nil { @@ -1901,7 +1943,8 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.OfType(), nil }) if resTmp == nil { diff --git a/example/starwars/generated.go b/example/starwars/generated.go index 2dbc6ff436e..c2fb5d57b52 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -877,7 +877,8 @@ func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.Collect Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -899,7 +900,8 @@ func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -921,8 +923,9 @@ func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Droid().Friends(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Droid().Friends(rctx, obj) }) if resTmp == nil { return graphql.Null @@ -979,8 +982,9 @@ func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Droid().FriendsConnection(ctx, obj, args["first"].(*int), args["after"].(*string)) + resTmp := ec.FieldMiddleware(ctx, obj, 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)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1002,7 +1006,8 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.AppearsIn, nil }) if resTmp == nil { @@ -1033,7 +1038,8 @@ func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.PrimaryFunction, nil }) if resTmp == nil { @@ -1100,7 +1106,8 @@ func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, f Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.TotalCount(), nil }) if resTmp == nil { @@ -1122,8 +1129,9 @@ func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.FriendsConnection().Edges(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.FriendsConnection().Edges(rctx, obj) }) if resTmp == nil { return graphql.Null @@ -1174,8 +1182,9 @@ func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.FriendsConnection().Friends(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.FriendsConnection().Friends(rctx, obj) }) if resTmp == nil { return graphql.Null @@ -1226,7 +1235,8 @@ func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, fie Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.PageInfo(), nil }) if resTmp == nil { @@ -1281,7 +1291,8 @@ func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Cursor, nil }) if resTmp == nil { @@ -1303,7 +1314,8 @@ func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Node, nil }) if resTmp == nil { @@ -1392,7 +1404,8 @@ func (ec *executionContext) _Human_id(ctx context.Context, field graphql.Collect Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1414,7 +1427,8 @@ func (ec *executionContext) _Human_name(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1442,7 +1456,8 @@ func (ec *executionContext) _Human_height(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Height(args["unit"].(LengthUnit)), nil }) if resTmp == nil { @@ -1464,7 +1479,8 @@ func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Mass, nil }) if resTmp == nil { @@ -1483,8 +1499,9 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Human().Friends(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Human().Friends(rctx, obj) }) if resTmp == nil { return graphql.Null @@ -1541,8 +1558,9 @@ func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Human().FriendsConnection(ctx, obj, args["first"].(*int), args["after"].(*string)) + resTmp := ec.FieldMiddleware(ctx, obj, 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)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1564,7 +1582,8 @@ func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.AppearsIn, nil }) if resTmp == nil { @@ -1595,8 +1614,9 @@ func (ec *executionContext) _Human_starships(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Human().Starships(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Human().Starships(rctx, obj) }) if resTmp == nil { return graphql.Null @@ -1684,8 +1704,9 @@ func (ec *executionContext) _Mutation_createReview(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Mutation().CreateReview(ctx, args["episode"].(Episode), args["review"].(Review)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateReview(rctx, args["episode"].(Episode), args["review"].(Review)) }) if resTmp == nil { return graphql.Null @@ -1748,7 +1769,8 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.StartCursor, nil }) if resTmp == nil { @@ -1770,7 +1792,8 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.EndCursor, nil }) if resTmp == nil { @@ -1792,7 +1815,8 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.HasNextPage, nil }) if resTmp == nil { @@ -1902,8 +1926,9 @@ func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Hero(ctx, args["episode"].(Episode)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Hero(rctx, args["episode"].(Episode)) }) if resTmp == nil { return graphql.Null @@ -1928,8 +1953,9 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Reviews(ctx, args["episode"].(Episode), args["since"].(*time.Time)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Reviews(rctx, args["episode"].(Episode), args["since"].(*time.Time)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1989,8 +2015,9 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Search(ctx, args["text"].(string)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Search(rctx, args["text"].(string)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -2050,8 +2077,9 @@ func (ec *executionContext) _Query_character(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Character(ctx, args["id"].(string)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Character(rctx, args["id"].(string)) }) if resTmp == nil { return graphql.Null @@ -2076,8 +2104,9 @@ func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Droid(ctx, args["id"].(string)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Droid(rctx, args["id"].(string)) }) if resTmp == nil { return graphql.Null @@ -2106,8 +2135,9 @@ func (ec *executionContext) _Query_human(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Human(ctx, args["id"].(string)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Human(rctx, args["id"].(string)) }) if resTmp == nil { return graphql.Null @@ -2136,8 +2166,9 @@ func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Starship(ctx, args["id"].(string)) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Starship(rctx, args["id"].(string)) }) if resTmp == nil { return graphql.Null @@ -2166,7 +2197,8 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + 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)), nil }) if resTmp == nil { @@ -2190,7 +2222,8 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return ec.introspectSchema(), nil }) if resTmp == nil { @@ -2248,7 +2281,8 @@ func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Stars, nil }) if resTmp == nil { @@ -2270,7 +2304,8 @@ func (ec *executionContext) _Review_commentary(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Commentary, nil }) if resTmp == nil { @@ -2293,7 +2328,8 @@ func (ec *executionContext) _Review_time(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Time, nil }) if resTmp == nil { @@ -2362,7 +2398,8 @@ func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2384,7 +2421,8 @@ func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2412,8 +2450,9 @@ func (ec *executionContext) _Starship_length(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Starship().Length(ctx, obj, args["unit"].(LengthUnit)) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Starship().Length(rctx, obj, args["unit"].(LengthUnit)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -2434,7 +2473,8 @@ func (ec *executionContext) _Starship_history(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.History, nil }) if resTmp == nil { @@ -2516,7 +2556,8 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2538,7 +2579,8 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -2557,7 +2599,8 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2588,7 +2631,8 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2682,7 +2726,8 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2704,7 +2749,8 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -2723,7 +2769,8 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2745,7 +2792,8 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -2813,7 +2861,8 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2835,7 +2884,8 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -2854,7 +2904,8 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2909,7 +2960,8 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2939,7 +2991,8 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -2961,7 +3014,8 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -3019,7 +3073,8 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -3041,7 +3096,8 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -3060,7 +3116,8 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -3090,7 +3147,8 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil }) if resTmp == nil { @@ -3157,7 +3215,8 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -3212,7 +3271,8 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -3242,7 +3302,8 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil }) if resTmp == nil { @@ -3266,7 +3327,8 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -3290,7 +3352,8 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -3391,7 +3454,8 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -3413,7 +3477,8 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -3436,7 +3501,8 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if resTmp == nil { @@ -3461,7 +3527,8 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -3513,7 +3580,8 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil }) if resTmp == nil { @@ -3565,7 +3633,8 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -3623,7 +3692,8 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -3675,7 +3745,8 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil }) if resTmp == nil { @@ -3727,7 +3798,8 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.OfType(), nil }) if resTmp == nil { diff --git a/example/todo/generated.go b/example/todo/generated.go index b1d2c500dbf..11e59c7ef63 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -361,8 +361,9 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.MyMutation().CreateTodo(ctx, args["todo"].(TodoInput)) + 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) { @@ -390,8 +391,9 @@ func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.MyMutation().UpdateTodo(ctx, args["id"].(int), args["changes"].(map[string]interface{})) + 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{})) }) if resTmp == nil { return graphql.Null @@ -475,8 +477,9 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.MyQuery().Todo(ctx, args["id"].(int)) + 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)) }) if resTmp == nil { return graphql.Null @@ -499,8 +502,9 @@ func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.MyQuery().LastTodo(ctx) + 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) }) if resTmp == nil { return graphql.Null @@ -523,8 +527,9 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.MyQuery().Todos(ctx) + 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) { @@ -584,7 +589,8 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + 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)), nil }) if resTmp == nil { @@ -608,7 +614,8 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return ec.introspectSchema(), nil }) if resTmp == nil { @@ -672,7 +679,8 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -694,7 +702,8 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -716,7 +725,8 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Done, nil }) if resTmp == nil { @@ -780,7 +790,8 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -802,7 +813,8 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -821,7 +833,8 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -852,7 +865,8 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -946,7 +960,8 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -968,7 +983,8 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -987,7 +1003,8 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1009,7 +1026,8 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1077,7 +1095,8 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1099,7 +1118,8 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1118,7 +1138,8 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1173,7 +1194,8 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1203,7 +1225,8 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1225,7 +1248,8 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1283,7 +1307,8 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1305,7 +1330,8 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1324,7 +1350,8 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1354,7 +1381,8 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil }) if resTmp == nil { @@ -1421,7 +1449,8 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1476,7 +1505,8 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1506,7 +1536,8 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil }) if resTmp == nil { @@ -1530,7 +1561,8 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1554,7 +1586,8 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1655,7 +1688,8 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1677,7 +1711,8 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1700,7 +1735,8 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if resTmp == nil { @@ -1725,7 +1761,8 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -1777,7 +1814,8 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil }) if resTmp == nil { @@ -1829,7 +1867,8 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -1887,7 +1926,8 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -1939,7 +1979,8 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil }) if resTmp == nil { @@ -1991,7 +2032,8 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.OfType(), nil }) if resTmp == nil { diff --git a/integration/generated.go b/integration/generated.go index ddd917dee6f..c598e8ad47c 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -368,8 +368,9 @@ func (ec *executionContext) _Element_child(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Element().Child(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Element().Child(rctx, obj) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -391,8 +392,9 @@ func (ec *executionContext) _Element_error(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Element().Error(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Element().Error(rctx, obj) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -413,8 +415,9 @@ func (ec *executionContext) _Element_mismatched(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Element().Mismatched(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Element().Mismatched(rctx, obj) }) if resTmp == nil { return graphql.Null @@ -514,8 +517,9 @@ func (ec *executionContext) _Query_path(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Path(ctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Path(rctx) }) if resTmp == nil { return graphql.Null @@ -576,8 +580,9 @@ func (ec *executionContext) _Query_date(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Date(ctx, args["filter"].(models.DateFilter)) + resTmp := ec.FieldMiddleware(ctx, nil, 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)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -598,8 +603,9 @@ func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Viewer(ctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Viewer(rctx) }) if resTmp == nil { return graphql.Null @@ -622,8 +628,9 @@ func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().JSONEncoding(ctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().JSONEncoding(rctx) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -650,8 +657,9 @@ func (ec *executionContext) _Query_error(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Error(ctx, args["type"].(models.ErrorType)) + resTmp := ec.FieldMiddleware(ctx, nil, 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)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -678,7 +686,8 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + 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)), nil }) if resTmp == nil { @@ -702,7 +711,8 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return ec.introspectSchema(), nil }) if resTmp == nil { @@ -766,7 +776,8 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -788,8 +799,9 @@ func (ec *executionContext) _User_likes(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.User().Likes(ctx, obj) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().Likes(rctx, obj) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -846,7 +858,8 @@ func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.User, nil }) if resTmp == nil { @@ -912,7 +925,8 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -934,7 +948,8 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -953,7 +968,8 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -984,7 +1000,8 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1078,7 +1095,8 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1100,7 +1118,8 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1119,7 +1138,8 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1141,7 +1161,8 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1209,7 +1230,8 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1231,7 +1253,8 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1250,7 +1273,8 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1305,7 +1329,8 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1335,7 +1360,8 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1357,7 +1383,8 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1415,7 +1442,8 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1437,7 +1465,8 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if resTmp == nil { @@ -1456,7 +1485,8 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1486,7 +1516,8 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil }) if resTmp == nil { @@ -1553,7 +1584,8 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1608,7 +1640,8 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1638,7 +1671,8 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil }) if resTmp == nil { @@ -1662,7 +1696,8 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1686,7 +1721,8 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1787,7 +1823,8 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1809,7 +1846,8 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 { @@ -1832,7 +1870,8 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if resTmp == nil { @@ -1857,7 +1896,8 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -1909,7 +1949,8 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil }) if resTmp == nil { @@ -1961,7 +2002,8 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -2019,7 +2061,8 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + 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 }) if resTmp == nil { @@ -2071,7 +2114,8 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil }) if resTmp == nil { @@ -2123,7 +2167,8 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children return obj.OfType(), nil }) if resTmp == nil {