From e35812ff792290a5281a649b4a572e2f2f870419 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Fri, 24 Aug 2018 10:53:47 +1000 Subject: [PATCH] Add obj to Directives --- codegen/directive.go | 4 +- codegen/templates/data.go | 4 +- codegen/templates/field.gotpl | 2 +- codegen/templates/generated.gotpl | 2 +- codegen/testserver/generated.go | 120 +++++++++++----------- example/chat/generated.go | 86 ++++++++-------- example/config/generated.go | 88 ++++++++-------- example/dataloader/generated.go | 100 +++++++++--------- example/scalars/generated.go | 94 ++++++++--------- example/selection/generated.go | 88 ++++++++-------- example/starwars/generated.go | 146 +++++++++++++------------- example/todo/generated.go | 164 +++++++++++------------------- example/todo/gqlgen.yml | 3 + example/todo/models.go | 21 ++++ example/todo/models_gen.go | 9 +- example/todo/schema.graphql | 31 +++--- example/todo/todo.go | 45 +++++--- example/todo/todo_test.go | 43 ++++---- integration/generated.go | 96 ++++++++--------- 19 files changed, 567 insertions(+), 579 deletions(-) create mode 100644 example/todo/gqlgen.yml create mode 100644 example/todo/models.go diff --git a/codegen/directive.go b/codegen/directive.go index ee49788bc2f..7051c03c675 100644 --- a/codegen/directive.go +++ b/codegen/directive.go @@ -12,7 +12,7 @@ type Directive struct { } func (d *Directive) CallArgs() string { - args := []string{"ctx", "n"} + args := []string{"ctx", "obj", "n"} for _, arg := range d.Args { args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+arg.Signature()+")") @@ -22,7 +22,7 @@ func (d *Directive) CallArgs() string { } func (d *Directive) Declaration() string { - res := ucFirst(d.Name) + " func(ctx context.Context, next graphql.Resolver" + res := ucFirst(d.Name) + " func(ctx context.Context, obj interface{}, next graphql.Resolver" for _, arg := range d.Args { res += fmt.Sprintf(", %s %s", arg.GoVarName, arg.Signature()) diff --git a/codegen/templates/data.go b/codegen/templates/data.go index db2816c0234..3625fe4247b 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -2,8 +2,8 @@ package templates var data = map[string]string{ "args.gotpl": "\t{{- if . }}args := map[string]interface{}{} {{end}}\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\tec.Error(ctx, err)\n\t\t\t\t{{- if $arg.Stream }}\n\t\t\t\t\treturn nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn graphql.Null\n\t\t\t\t{{- end }}\n\t\t\t}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- 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\t{{ template \"args.gotpl\" $field.Args }}\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\t{{ template \"args.gotpl\" $field.Args }}\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, 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", - "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}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\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\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\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\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}\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}\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\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\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, 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\t{{ template \"args.gotpl\" $directive.Args }}\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", + "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\t{{ template \"args.gotpl\" $field.Args }}\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\t{{ template \"args.gotpl\" $field.Args }}\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", + "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}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\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\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\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\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}\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}\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\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\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\t{{ template \"args.gotpl\" $directive.Args }}\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", "models.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{{ range $model := .Models }}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- if $field.GoFieldName }}\n\t\t\t\t\t{{ $field.GoFieldName }} {{$field.Signature}} `json:\"{{$field.GQLName}}\"`\n\t\t\t\t{{- else }}\n\t\t\t\t\t{{ $field.GoFKName }} {{$field.GoFKType}}\n\t\t\t\t{{- end }}\n\t\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\ttype {{.GoType}} string\n\tconst (\n\t{{ range $value := .Values -}}\n\t\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t\t{{$enum.GoType}}{{ .Name|toCamel }} {{$enum.GoType}} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tfunc (e {{.GoType}}) IsValid() bool {\n\t\tswitch e {\n\t\tcase {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.GoType }}{{ $element.Name|toCamel }}{{end}}:\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tfunc (e {{.GoType}}) String() string {\n\t\treturn string(e)\n\t}\n\n\tfunc (e *{{.GoType}}) UnmarshalGQL(v interface{}) error {\n\t\tstr, ok := v.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"enums must be strings\")\n\t\t}\n\n\t\t*e = {{.GoType}}(str)\n\t\tif !e.IsValid() {\n\t\t\treturn fmt.Errorf(\"%s is not a valid {{.GQLType}}\", str)\n\t\t}\n\t\treturn nil\n\t}\n\n\tfunc (e {{.GoType}}) MarshalGQL(w io.Writer) {\n\t\tfmt.Fprint(w, strconv.Quote(e.String()))\n\t}\n\n{{- end }}\n", diff --git a/codegen/templates/field.gotpl b/codegen/templates/field.gotpl index ca4d81f4259..8ff21347685 100644 --- a/codegen/templates/field.gotpl +++ b/codegen/templates/field.gotpl @@ -38,7 +38,7 @@ Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(ctx context.Context) (interface{}, error) { {{- if $field.IsResolver }} return ec.resolvers.{{ $field.ShortInvocation }} {{- else if $field.IsMethod }} diff --git a/codegen/templates/generated.gotpl b/codegen/templates/generated.gotpl index c6b093db6e3..26c0f323e40 100644 --- a/codegen/templates/generated.gotpl +++ b/codegen/templates/generated.gotpl @@ -147,7 +147,7 @@ type executionContext struct { {{ template "input.gotpl" $input }} {{- end }} -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index d5dd9431f73..3402ee3dcef 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -129,7 +129,7 @@ func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Radius, nil }) if resTmp == nil { @@ -148,7 +148,7 @@ func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Area(), nil }) if resTmp == nil { @@ -209,7 +209,7 @@ func (ec *executionContext) _Error_id(ctx context.Context, field graphql.Collect Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -231,7 +231,7 @@ func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ErrorOnNonRequiredField() }) if resTmp == nil { @@ -250,7 +250,7 @@ func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, fie Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ErrorOnRequiredField() }) if resTmp == nil { @@ -272,7 +272,7 @@ func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.NilOnRequiredField(), nil }) if resTmp == nil { @@ -333,7 +333,7 @@ func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.ForcedResolver().Field(ctx, obj) }) if resTmp == nil { @@ -387,7 +387,7 @@ func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -439,7 +439,7 @@ func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -491,7 +491,7 @@ func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedF Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -543,7 +543,7 @@ func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Inner, nil }) if resTmp == nil { @@ -675,7 +675,7 @@ func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().InvalidIdentifier(ctx) }) if resTmp == nil { @@ -699,7 +699,7 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Collision(ctx) }) if resTmp == nil { @@ -740,7 +740,7 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().MapInput(ctx, args["input"].(*map[string]interface{})) }) if resTmp == nil { @@ -780,7 +780,7 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Recursive(ctx, args["input"].(*RecursiveInputSlice)) }) if resTmp == nil { @@ -841,7 +841,7 @@ func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().NestedInputs(ctx, args["input"].([][]*OuterInput)) }) if resTmp == nil { @@ -864,7 +864,7 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().NestedOutputs(ctx) }) if resTmp == nil { @@ -927,7 +927,7 @@ func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Keywords(ctx, args["input"].(*Keywords)) }) if resTmp == nil { @@ -949,7 +949,7 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Shapes(ctx) }) if resTmp == nil { @@ -984,7 +984,7 @@ func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().ErrorBubble(ctx) }) if resTmp == nil { @@ -1008,7 +1008,7 @@ func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Valid(ctx) }) if resTmp == nil { @@ -1282,7 +1282,7 @@ func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + 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)) }) if resTmp == nil { @@ -1316,7 +1316,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) if resTmp == nil { @@ -1340,7 +1340,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) if resTmp == nil { @@ -1395,7 +1395,7 @@ func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Length, nil }) if resTmp == nil { @@ -1414,7 +1414,7 @@ func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Width, nil }) if resTmp == nil { @@ -1433,7 +1433,7 @@ func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Area(), nil }) if resTmp == nil { @@ -1494,7 +1494,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1516,7 +1516,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1535,7 +1535,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) if resTmp == nil { @@ -1563,7 +1563,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -1636,7 +1636,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1658,7 +1658,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1677,7 +1677,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -1699,7 +1699,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1767,7 +1767,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1789,7 +1789,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1808,7 +1808,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -1842,7 +1842,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -1872,7 +1872,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -1894,7 +1894,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1952,7 +1952,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1974,7 +1974,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1993,7 +1993,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -2023,7 +2023,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) if resTmp == nil { @@ -2090,7 +2090,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) if resTmp == nil { @@ -2124,7 +2124,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) if resTmp == nil { @@ -2154,7 +2154,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) if resTmp == nil { @@ -2178,7 +2178,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -2202,7 +2202,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) if resTmp == nil { @@ -2282,7 +2282,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) if resTmp == nil { @@ -2304,7 +2304,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) if resTmp == nil { @@ -2327,7 +2327,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) if resTmp == nil { @@ -2358,7 +2358,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -2389,7 +2389,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) if resTmp == nil { @@ -2420,7 +2420,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -2463,7 +2463,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -2494,7 +2494,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) if resTmp == nil { @@ -2525,7 +2525,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) if resTmp == nil { @@ -2794,7 +2794,7 @@ func UnmarshalRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { return it, nil } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) diff --git a/example/chat/generated.go b/example/chat/generated.go index e634ff91d7e..b9be4e6d379 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -163,7 +163,7 @@ func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -185,7 +185,7 @@ func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Messages, nil }) if resTmp == nil { @@ -264,7 +264,7 @@ func (ec *executionContext) _Message_id(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -286,7 +286,7 @@ func (ec *executionContext) _Message_text(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Text, nil }) if resTmp == nil { @@ -308,7 +308,7 @@ func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.CreatedBy, nil }) if resTmp == nil { @@ -330,7 +330,7 @@ func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.CreatedAt, nil }) if resTmp == nil { @@ -418,7 +418,7 @@ func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + 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)) }) if resTmp == nil { @@ -493,7 +493,7 @@ func (ec *executionContext) _Query_room(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Room(ctx, args["name"].(string)) }) if resTmp == nil { @@ -529,7 +529,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) if resTmp == nil { @@ -553,7 +553,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) if resTmp == nil { @@ -674,7 +674,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -696,7 +696,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -715,7 +715,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) if resTmp == nil { @@ -743,7 +743,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -816,7 +816,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -838,7 +838,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -857,7 +857,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -879,7 +879,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -947,7 +947,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -969,7 +969,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -988,7 +988,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -1022,7 +1022,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -1052,7 +1052,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -1074,7 +1074,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1132,7 +1132,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1154,7 +1154,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1173,7 +1173,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -1203,7 +1203,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) if resTmp == nil { @@ -1270,7 +1270,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) if resTmp == nil { @@ -1304,7 +1304,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) if resTmp == nil { @@ -1334,7 +1334,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) if resTmp == nil { @@ -1358,7 +1358,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1382,7 +1382,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) if resTmp == nil { @@ -1462,7 +1462,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) if resTmp == nil { @@ -1484,7 +1484,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) if resTmp == nil { @@ -1507,7 +1507,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) if resTmp == nil { @@ -1538,7 +1538,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1569,7 +1569,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) if resTmp == nil { @@ -1600,7 +1600,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -1643,7 +1643,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1674,7 +1674,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) if resTmp == nil { @@ -1705,7 +1705,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) if resTmp == nil { @@ -1721,7 +1721,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return ec.___Type(ctx, field.Selections, res) } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) diff --git a/example/config/generated.go b/example/config/generated.go index b8cb067bac0..fa61d1c9894 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -149,7 +149,7 @@ func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Mutation().CreateTodo(ctx, args["input"].(NewTodo)) }) if resTmp == nil { @@ -215,7 +215,7 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Todos(ctx) }) if resTmp == nil { @@ -261,7 +261,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) if resTmp == nil { @@ -285,7 +285,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) if resTmp == nil { @@ -364,7 +364,7 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Todo().ID(ctx, obj) }) if resTmp == nil { @@ -386,7 +386,7 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DatabaseID, nil }) if resTmp == nil { @@ -408,7 +408,7 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -430,7 +430,7 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Done, nil }) if resTmp == nil { @@ -452,7 +452,7 @@ func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.User, nil }) if resTmp == nil { @@ -510,7 +510,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -532,7 +532,7 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.FullName(), nil }) if resTmp == nil { @@ -596,7 +596,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -618,7 +618,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -637,7 +637,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) if resTmp == nil { @@ -665,7 +665,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -738,7 +738,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -760,7 +760,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -779,7 +779,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -801,7 +801,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -869,7 +869,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -891,7 +891,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -910,7 +910,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -944,7 +944,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -974,7 +974,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -996,7 +996,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1054,7 +1054,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1076,7 +1076,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1095,7 +1095,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -1125,7 +1125,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) if resTmp == nil { @@ -1192,7 +1192,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) if resTmp == nil { @@ -1226,7 +1226,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) if resTmp == nil { @@ -1256,7 +1256,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) if resTmp == nil { @@ -1280,7 +1280,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1304,7 +1304,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) if resTmp == nil { @@ -1384,7 +1384,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) if resTmp == nil { @@ -1406,7 +1406,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) if resTmp == nil { @@ -1429,7 +1429,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) if resTmp == nil { @@ -1460,7 +1460,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1491,7 +1491,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) if resTmp == nil { @@ -1522,7 +1522,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -1565,7 +1565,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1596,7 +1596,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) if resTmp == nil { @@ -1627,7 +1627,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) if resTmp == nil { @@ -1667,7 +1667,7 @@ func UnmarshalNewTodo(v interface{}) (NewTodo, error) { return it, nil } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index cc027df1569..278d5f7285c 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -135,7 +135,7 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -157,7 +157,7 @@ func (ec *executionContext) _Address_street(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Street, nil }) if resTmp == nil { @@ -179,7 +179,7 @@ func (ec *executionContext) _Address_country(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Country, nil }) if resTmp == nil { @@ -249,7 +249,7 @@ func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -271,7 +271,7 @@ func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -293,7 +293,7 @@ func (ec *executionContext) _Customer_address(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Customer().Address(ctx, obj) }) if resTmp == nil { @@ -317,7 +317,7 @@ func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Customer().Orders(ctx, obj) }) if resTmp == nil { @@ -378,7 +378,7 @@ func (ec *executionContext) _Item_name(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -447,7 +447,7 @@ func (ec *executionContext) _Order_id(ctx context.Context, field graphql.Collect Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -469,7 +469,7 @@ func (ec *executionContext) _Order_date(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Date, nil }) if resTmp == nil { @@ -491,7 +491,7 @@ func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Amount, nil }) if resTmp == nil { @@ -513,7 +513,7 @@ func (ec *executionContext) _Order_items(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Order().Items(ctx, obj) }) if resTmp == nil { @@ -596,7 +596,7 @@ func (ec *executionContext) _Query_customers(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Customers(ctx) }) if resTmp == nil { @@ -650,7 +650,7 @@ func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Torture1d(ctx, args["customerIds"].([]int)) }) if resTmp == nil { @@ -715,7 +715,7 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Torture2d(ctx, args["customerIds"].([][]int)) }) if resTmp == nil { @@ -769,7 +769,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) if resTmp == nil { @@ -793,7 +793,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) if resTmp == nil { @@ -859,7 +859,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -881,7 +881,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -900,7 +900,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) if resTmp == nil { @@ -928,7 +928,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -1001,7 +1001,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1023,7 +1023,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1042,7 +1042,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -1064,7 +1064,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1132,7 +1132,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1154,7 +1154,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1173,7 +1173,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -1207,7 +1207,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -1237,7 +1237,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -1259,7 +1259,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1317,7 +1317,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1339,7 +1339,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1358,7 +1358,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -1388,7 +1388,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) if resTmp == nil { @@ -1455,7 +1455,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) if resTmp == nil { @@ -1489,7 +1489,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) if resTmp == nil { @@ -1519,7 +1519,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) if resTmp == nil { @@ -1543,7 +1543,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1567,7 +1567,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) if resTmp == nil { @@ -1647,7 +1647,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) if resTmp == nil { @@ -1669,7 +1669,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) if resTmp == nil { @@ -1692,7 +1692,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) if resTmp == nil { @@ -1723,7 +1723,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1754,7 +1754,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) if resTmp == nil { @@ -1785,7 +1785,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -1828,7 +1828,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1859,7 +1859,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) if resTmp == nil { @@ -1890,7 +1890,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) if resTmp == nil { @@ -1906,7 +1906,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return ec.___Type(ctx, field.Selections, res) } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) diff --git a/example/scalars/generated.go b/example/scalars/generated.go index c4207e32199..b10520bbe00 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -124,7 +124,7 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -146,7 +146,7 @@ func (ec *executionContext) _Address_location(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Location, nil }) if resTmp == nil { @@ -230,7 +230,7 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().User(ctx, args["id"].(external.ObjectID)) }) if resTmp == nil { @@ -266,7 +266,7 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Search(ctx, args["input"].(model.SearchArgs)) }) if resTmp == nil { @@ -312,7 +312,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) if resTmp == nil { @@ -336,7 +336,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) if resTmp == nil { @@ -425,7 +425,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -447,7 +447,7 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -469,7 +469,7 @@ func (ec *executionContext) _User_created(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Created, nil }) if resTmp == nil { @@ -488,7 +488,7 @@ func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsBanned, nil }) if resTmp == nil { @@ -510,7 +510,7 @@ func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field g Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.User().PrimitiveResolver(ctx, obj) }) if resTmp == nil { @@ -532,7 +532,7 @@ func (ec *executionContext) _User_customResolver(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.User().CustomResolver(ctx, obj) }) if resTmp == nil { @@ -554,7 +554,7 @@ func (ec *executionContext) _User_address(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Address, nil }) if resTmp == nil { @@ -574,7 +574,7 @@ func (ec *executionContext) _User_tier(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Tier, nil }) if resTmp == nil { @@ -635,7 +635,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -657,7 +657,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -676,7 +676,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) if resTmp == nil { @@ -704,7 +704,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -777,7 +777,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -799,7 +799,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -818,7 +818,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -840,7 +840,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -908,7 +908,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -930,7 +930,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -949,7 +949,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -983,7 +983,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -1013,7 +1013,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -1035,7 +1035,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1093,7 +1093,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1115,7 +1115,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1134,7 +1134,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -1164,7 +1164,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) if resTmp == nil { @@ -1231,7 +1231,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) if resTmp == nil { @@ -1265,7 +1265,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) if resTmp == nil { @@ -1295,7 +1295,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) if resTmp == nil { @@ -1319,7 +1319,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1343,7 +1343,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) if resTmp == nil { @@ -1423,7 +1423,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) if resTmp == nil { @@ -1445,7 +1445,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) if resTmp == nil { @@ -1468,7 +1468,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) if resTmp == nil { @@ -1499,7 +1499,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1530,7 +1530,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) if resTmp == nil { @@ -1561,7 +1561,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -1604,7 +1604,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1635,7 +1635,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) if resTmp == nil { @@ -1666,7 +1666,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) if resTmp == nil { @@ -1725,7 +1725,7 @@ func UnmarshalSearchArgs(v interface{}) (model.SearchArgs, error) { return it, nil } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) diff --git a/example/selection/generated.go b/example/selection/generated.go index ab508ececb7..ceaa5d93c66 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -124,7 +124,7 @@ func (ec *executionContext) _Like_reaction(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Reaction, nil }) if resTmp == nil { @@ -146,7 +146,7 @@ func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Sent, nil }) if resTmp == nil { @@ -168,7 +168,7 @@ func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Selection, nil }) if resTmp == nil { @@ -193,7 +193,7 @@ func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Collected, nil }) if resTmp == nil { @@ -257,7 +257,7 @@ func (ec *executionContext) _Post_message(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Message, nil }) if resTmp == nil { @@ -279,7 +279,7 @@ func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Sent, nil }) if resTmp == nil { @@ -301,7 +301,7 @@ func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Selection, nil }) if resTmp == nil { @@ -326,7 +326,7 @@ func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Collected, nil }) if resTmp == nil { @@ -391,7 +391,7 @@ func (ec *executionContext) _Query_events(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Events(ctx) }) if resTmp == nil { @@ -434,7 +434,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) if resTmp == nil { @@ -458,7 +458,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) if resTmp == nil { @@ -524,7 +524,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -546,7 +546,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -565,7 +565,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) if resTmp == nil { @@ -593,7 +593,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -666,7 +666,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -688,7 +688,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -707,7 +707,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -729,7 +729,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -797,7 +797,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -819,7 +819,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -838,7 +838,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -872,7 +872,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -902,7 +902,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -924,7 +924,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -982,7 +982,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1004,7 +1004,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1023,7 +1023,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -1053,7 +1053,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) if resTmp == nil { @@ -1120,7 +1120,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) if resTmp == nil { @@ -1154,7 +1154,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) if resTmp == nil { @@ -1184,7 +1184,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) if resTmp == nil { @@ -1208,7 +1208,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1232,7 +1232,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) if resTmp == nil { @@ -1312,7 +1312,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) if resTmp == nil { @@ -1334,7 +1334,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) if resTmp == nil { @@ -1357,7 +1357,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) if resTmp == nil { @@ -1388,7 +1388,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1419,7 +1419,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) if resTmp == nil { @@ -1450,7 +1450,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -1493,7 +1493,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1524,7 +1524,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) if resTmp == nil { @@ -1555,7 +1555,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) if resTmp == nil { @@ -1588,7 +1588,7 @@ func (ec *executionContext) _Event(ctx context.Context, sel ast.SelectionSet, ob } } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) diff --git a/example/starwars/generated.go b/example/starwars/generated.go index bd208bb5242..8237b1371da 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -186,7 +186,7 @@ func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.Collect Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -208,7 +208,7 @@ func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -230,7 +230,7 @@ func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Droid().Friends(ctx, obj) }) if resTmp == nil { @@ -293,7 +293,7 @@ func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Droid().FriendsConnection(ctx, obj, args["first"].(*int), args["after"].(*string)) }) if resTmp == nil { @@ -316,7 +316,7 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.AppearsIn, nil }) if resTmp == nil { @@ -344,7 +344,7 @@ func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.PrimaryFunction, nil }) if resTmp == nil { @@ -411,7 +411,7 @@ func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, f Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.TotalCount(), nil }) if resTmp == nil { @@ -433,7 +433,7 @@ func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.FriendsConnection().Edges(ctx, obj) }) if resTmp == nil { @@ -464,7 +464,7 @@ func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.FriendsConnection().Friends(ctx, obj) }) if resTmp == nil { @@ -495,7 +495,7 @@ func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, fie Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.PageInfo(), nil }) if resTmp == nil { @@ -550,7 +550,7 @@ func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Cursor, nil }) if resTmp == nil { @@ -572,7 +572,7 @@ func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Node, nil }) if resTmp == nil { @@ -661,7 +661,7 @@ func (ec *executionContext) _Human_id(ctx context.Context, field graphql.Collect Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -683,7 +683,7 @@ func (ec *executionContext) _Human_name(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -717,7 +717,7 @@ func (ec *executionContext) _Human_height(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Height(args["unit"].(LengthUnit)), nil }) if resTmp == nil { @@ -739,7 +739,7 @@ func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Mass, nil }) if resTmp == nil { @@ -758,7 +758,7 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Human().Friends(ctx, obj) }) if resTmp == nil { @@ -821,7 +821,7 @@ func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Human().FriendsConnection(ctx, obj, args["first"].(*int), args["after"].(*string)) }) if resTmp == nil { @@ -844,7 +844,7 @@ func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.AppearsIn, nil }) if resTmp == nil { @@ -872,7 +872,7 @@ func (ec *executionContext) _Human_starships(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Human().Starships(ctx, obj) }) if resTmp == nil { @@ -956,7 +956,7 @@ func (ec *executionContext) _Mutation_createReview(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Mutation().CreateReview(ctx, args["episode"].(Episode), args["review"].(Review)) }) if resTmp == nil { @@ -1020,7 +1020,7 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.StartCursor, nil }) if resTmp == nil { @@ -1042,7 +1042,7 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.EndCursor, nil }) if resTmp == nil { @@ -1064,7 +1064,7 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.HasNextPage, nil }) if resTmp == nil { @@ -1180,7 +1180,7 @@ func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Hero(ctx, args["episode"].(Episode)) }) if resTmp == nil { @@ -1227,7 +1227,7 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Reviews(ctx, args["episode"].(Episode), args["since"].(*time.Time)) }) if resTmp == nil { @@ -1273,7 +1273,7 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Search(ctx, args["text"].(string)) }) if resTmp == nil { @@ -1319,7 +1319,7 @@ func (ec *executionContext) _Query_character(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Character(ctx, args["id"].(string)) }) if resTmp == nil { @@ -1351,7 +1351,7 @@ func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Droid(ctx, args["id"].(string)) }) if resTmp == nil { @@ -1387,7 +1387,7 @@ func (ec *executionContext) _Query_human(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Human(ctx, args["id"].(string)) }) if resTmp == nil { @@ -1423,7 +1423,7 @@ func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Starship(ctx, args["id"].(string)) }) if resTmp == nil { @@ -1459,7 +1459,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) if resTmp == nil { @@ -1483,7 +1483,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) if resTmp == nil { @@ -1541,7 +1541,7 @@ func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Stars, nil }) if resTmp == nil { @@ -1563,7 +1563,7 @@ func (ec *executionContext) _Review_commentary(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Commentary, nil }) if resTmp == nil { @@ -1586,7 +1586,7 @@ func (ec *executionContext) _Review_time(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Time, nil }) if resTmp == nil { @@ -1655,7 +1655,7 @@ func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -1677,7 +1677,7 @@ func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1711,7 +1711,7 @@ func (ec *executionContext) _Starship_length(ctx context.Context, field graphql. Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Starship().Length(ctx, obj, args["unit"].(LengthUnit)) }) if resTmp == nil { @@ -1733,7 +1733,7 @@ func (ec *executionContext) _Starship_history(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.History, nil }) if resTmp == nil { @@ -1809,7 +1809,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1831,7 +1831,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1850,7 +1850,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) if resTmp == nil { @@ -1878,7 +1878,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -1951,7 +1951,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1973,7 +1973,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1992,7 +1992,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -2014,7 +2014,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -2082,7 +2082,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -2104,7 +2104,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -2123,7 +2123,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -2157,7 +2157,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -2187,7 +2187,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -2209,7 +2209,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -2267,7 +2267,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -2289,7 +2289,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -2308,7 +2308,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -2338,7 +2338,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) if resTmp == nil { @@ -2405,7 +2405,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) if resTmp == nil { @@ -2439,7 +2439,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) if resTmp == nil { @@ -2469,7 +2469,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) if resTmp == nil { @@ -2493,7 +2493,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -2517,7 +2517,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) if resTmp == nil { @@ -2597,7 +2597,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) if resTmp == nil { @@ -2619,7 +2619,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) if resTmp == nil { @@ -2642,7 +2642,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) if resTmp == nil { @@ -2673,7 +2673,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -2704,7 +2704,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) if resTmp == nil { @@ -2735,7 +2735,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -2778,7 +2778,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -2809,7 +2809,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) if resTmp == nil { @@ -2840,7 +2840,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) if resTmp == nil { @@ -2929,7 +2929,7 @@ func UnmarshalReviewInput(v interface{}) (Review, error) { return it, nil } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) diff --git a/example/todo/generated.go b/example/todo/generated.go index 559b103e73c..13164a1e6e9 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -33,7 +33,7 @@ type ResolverRoot interface { } type DirectiveRoot struct { - HasRole func(ctx context.Context, next graphql.Resolver, role Role) (res interface{}, err error) + HasRole func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (res interface{}, err error) } type MyMutationResolver interface { CreateTodo(ctx context.Context, todo TodoInput) (Todo, error) @@ -41,7 +41,6 @@ type MyMutationResolver interface { } type MyQueryResolver interface { Todo(ctx context.Context, id int) (*Todo, error) - AuthenticatedTodo(ctx context.Context, id int) (*Todo, error) LastTodo(ctx context.Context) (*Todo, error) Todos(ctx context.Context) ([]Todo, error) } @@ -152,7 +151,7 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.MyMutation().CreateTodo(ctx, args["todo"].(TodoInput)) }) if resTmp == nil { @@ -197,7 +196,7 @@ func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + 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{})) }) if resTmp == nil { @@ -238,12 +237,6 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) out.Values[i] = ec._MyQuery_todo(ctx, field) wg.Done() }(i, field) - case "authenticatedTodo": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._MyQuery_authenticatedTodo(ctx, field) - wg.Done() - }(i, field) case "lastTodo": wg.Add(1) go func(i int, field graphql.CollectedField) { @@ -294,7 +287,7 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.MyQuery().Todo(ctx, args["id"].(int)) }) if resTmp == nil { @@ -310,42 +303,6 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col return ec._Todo(ctx, field.Selections, res) } -// nolint: vetshadow -func (ec *executionContext) _MyQuery_authenticatedTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["id"] = arg0 - rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Args: args, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.MyQuery().AuthenticatedTodo(ctx, args["id"].(int)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Todo) - rctx.Result = res - - if res == nil { - return graphql.Null - } - - return ec._Todo(ctx, field.Selections, res) -} - // nolint: vetshadow func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rctx := &graphql.ResolverContext{ @@ -354,7 +311,7 @@ func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.MyQuery().LastTodo(ctx) }) if resTmp == nil { @@ -378,7 +335,7 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.MyQuery().Todos(ctx) }) if resTmp == nil { @@ -424,7 +381,7 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) if resTmp == nil { @@ -448,7 +405,7 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) if resTmp == nil { @@ -512,7 +469,7 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) if resTmp == nil { @@ -534,7 +491,7 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Text, nil }) if resTmp == nil { @@ -556,7 +513,7 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Done, nil }) if resTmp == nil { @@ -620,7 +577,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -642,7 +599,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -661,7 +618,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) if resTmp == nil { @@ -689,7 +646,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -762,7 +719,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -784,7 +741,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -803,7 +760,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -825,7 +782,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -893,7 +850,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -915,7 +872,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -934,7 +891,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -968,7 +925,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -998,7 +955,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -1020,7 +977,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1078,7 +1035,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1100,7 +1057,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1119,7 +1076,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -1149,7 +1106,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) if resTmp == nil { @@ -1216,7 +1173,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) if resTmp == nil { @@ -1250,7 +1207,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) if resTmp == nil { @@ -1280,7 +1237,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) if resTmp == nil { @@ -1304,7 +1261,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1328,7 +1285,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) if resTmp == nil { @@ -1408,7 +1365,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) if resTmp == nil { @@ -1430,7 +1387,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) if resTmp == nil { @@ -1453,7 +1410,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) if resTmp == nil { @@ -1484,7 +1441,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1515,7 +1472,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) if resTmp == nil { @@ -1546,7 +1503,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -1589,7 +1546,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1620,7 +1577,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) if resTmp == nil { @@ -1651,7 +1608,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) if resTmp == nil { @@ -1696,7 +1653,7 @@ func UnmarshalTodoInput(v interface{}) (TodoInput, error) { return it, nil } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1722,7 +1679,7 @@ func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Re args["role"] = arg0 n := next next = func(ctx context.Context) (interface{}, error) { - return ec.directives.HasRole(ctx, n, args["role"].(Role)) + return ec.directives.HasRole(ctx, obj, n, args["role"].(Role)) } } } @@ -1745,34 +1702,33 @@ func (ec *executionContext) introspectType(name string) *introspection.Type { var parsedSchema = gqlparser.MustLoadSchema( &ast.Source{Name: "schema.graphql", Input: `schema { - query: MyQuery - mutation: MyMutation + query: MyQuery + mutation: MyMutation } type MyQuery { - todo(id: Int!): Todo - authenticatedTodo(id: Int!): Todo @hasRole(role: ADMIN) - lastTodo: Todo - todos: [Todo!]! + todo(id: Int!): Todo + lastTodo: Todo + todos: [Todo!]! } type MyMutation { - createTodo(todo: TodoInput!): Todo! - updateTodo(id: Int!, changes: Map!): Todo + createTodo(todo: TodoInput!): Todo! + updateTodo(id: Int!, changes: Map!): Todo } type Todo { - id: Int! - text: String! - done: Boolean! + id: Int! + text: String! + done: Boolean! @hasRole(role: OWNER) # only the owner can see if a todo is done } "Passed to createTodo to create a new todo" input TodoInput { - "The body text" - text: String! - "Is it done already?" - done: Boolean + "The body text" + text: String! + "Is it done already?" + done: Boolean } scalar Map @@ -1782,7 +1738,7 @@ directive @hasRole(role: Role!) on FIELD_DEFINITION enum Role { ADMIN - USER + OWNER } `}, ) diff --git a/example/todo/gqlgen.yml b/example/todo/gqlgen.yml new file mode 100644 index 00000000000..5404738eb21 --- /dev/null +++ b/example/todo/gqlgen.yml @@ -0,0 +1,3 @@ +models: + Todo: + model: github.com/99designs/gqlgen/example/todo.Todo diff --git a/example/todo/models.go b/example/todo/models.go new file mode 100644 index 00000000000..2a5771c9e61 --- /dev/null +++ b/example/todo/models.go @@ -0,0 +1,21 @@ +package todo + +type Ownable interface { + Owner() *User +} + +type Todo struct { + ID int + Text string + Done bool + owner *User +} + +func (t Todo) Owner() *User { + return t.owner +} + +type User struct { + ID int + Name string +} diff --git a/example/todo/models_gen.go b/example/todo/models_gen.go index 8aa3fcaf34a..bcb243b53cb 100644 --- a/example/todo/models_gen.go +++ b/example/todo/models_gen.go @@ -8,11 +8,6 @@ import ( strconv "strconv" ) -type Todo struct { - ID int `json:"id"` - Text string `json:"text"` - Done bool `json:"done"` -} type TodoInput struct { Text string `json:"text"` Done *bool `json:"done"` @@ -22,12 +17,12 @@ type Role string const ( RoleAdmin Role = "ADMIN" - RoleUser Role = "USER" + RoleOwner Role = "OWNER" ) func (e Role) IsValid() bool { switch e { - case RoleAdmin, RoleUser: + case RoleAdmin, RoleOwner: return true } return false diff --git a/example/todo/schema.graphql b/example/todo/schema.graphql index 563a8daf0ff..b4263454cb8 100644 --- a/example/todo/schema.graphql +++ b/example/todo/schema.graphql @@ -1,32 +1,31 @@ schema { - query: MyQuery - mutation: MyMutation + query: MyQuery + mutation: MyMutation } type MyQuery { - todo(id: Int!): Todo - authenticatedTodo(id: Int!): Todo @hasRole(role: ADMIN) - lastTodo: Todo - todos: [Todo!]! + todo(id: Int!): Todo + lastTodo: Todo + todos: [Todo!]! } type MyMutation { - createTodo(todo: TodoInput!): Todo! - updateTodo(id: Int!, changes: Map!): Todo + createTodo(todo: TodoInput!): Todo! + updateTodo(id: Int!, changes: Map!): Todo } type Todo { - id: Int! - text: String! - done: Boolean! + id: Int! + text: String! + done: Boolean! @hasRole(role: OWNER) # only the owner can see if a todo is done } "Passed to createTodo to create a new todo" input TodoInput { - "The body text" - text: String! - "Is it done already?" - done: Boolean + "The body text" + text: String! + "Is it done already?" + done: Boolean } scalar Map @@ -36,5 +35,5 @@ directive @hasRole(role: Role!) on FIELD_DEFINITION enum Role { ADMIN - USER + OWNER } diff --git a/example/todo/todo.go b/example/todo/todo.go index ceeffdf75b6..dc51b3e8f69 100644 --- a/example/todo/todo.go +++ b/example/todo/todo.go @@ -5,30 +5,48 @@ package todo import ( "context" "errors" + "fmt" "time" "github.com/99designs/gqlgen/graphql" "github.com/mitchellh/mapstructure" ) +var you = &User{ID: 1, Name: "You"} +var them = &User{ID: 2, Name: "Them"} + func New() Config { c := Config{ Resolvers: &resolvers{ todos: []Todo{ - {ID: 1, Text: "A todo not to forget", Done: false}, - {ID: 2, Text: "This is the most important", Done: false}, - {ID: 3, Text: "Please do this or else", Done: false}, + {ID: 1, Text: "A todo not to forget", Done: false, owner: you}, + {ID: 2, Text: "This is the most important", Done: false, owner: you}, + {ID: 3, Text: "Somebody else's todo", Done: true, owner: them}, + {ID: 4, Text: "Please do this or else", Done: false, owner: you}, }, - lastID: 3, + lastID: 4, }, } - c.Directives.HasRole = func(ctx context.Context, next graphql.Resolver, role Role) (interface{}, error) { - rctx := graphql.GetResolverContext(ctx) - idVal := rctx.Field.Arguments.ForName("id").Value - id, _ := idVal.Value(make(map[string]interface{})) - if id.(int64) == 1 && role == RoleAdmin { + c.Directives.HasRole = func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (interface{}, error) { + switch role { + case RoleAdmin: + // No admin for you! return nil, nil + case RoleOwner: + // This is also available in context + if obj != graphql.GetResolverContext(ctx).Parent.Result { + return nil, fmt.Errorf("parent type mismatch") + } + ownable, isOwnable := obj.(Ownable) + if !isOwnable { + return nil, fmt.Errorf("obj cant be owned") + } + + if ownable.Owner().ID != you.ID { + return nil, fmt.Errorf("you dont own that") + } } + return next(ctx) } return c @@ -75,18 +93,15 @@ func (r *QueryResolver) Todos(ctx context.Context) ([]Todo, error) { return r.todos, nil } -func (r *QueryResolver) AuthenticatedTodo(ctx context.Context, id int) (*Todo, error) { - return r.Todo(ctx, id) -} - type MutationResolver resolvers func (r *MutationResolver) CreateTodo(ctx context.Context, todo TodoInput) (Todo, error) { newID := r.id() newTodo := Todo{ - ID: newID, - Text: todo.Text, + ID: newID, + Text: todo.Text, + owner: you, } if todo.Done != nil { diff --git a/example/todo/todo_test.go b/example/todo/todo_test.go index bd7dee60c91..04a4d557ec9 100644 --- a/example/todo/todo_test.go +++ b/example/todo/todo_test.go @@ -19,7 +19,7 @@ func TestTodo(t *testing.T) { } c.MustPost(`mutation { createTodo(todo:{text:"Fery important"}) { id } }`, &resp) - require.Equal(t, 4, resp.CreateTodo.ID) + require.Equal(t, 5, resp.CreateTodo.ID) t.Run("update the todo text", func(t *testing.T) { var resp struct { @@ -28,7 +28,7 @@ func TestTodo(t *testing.T) { c.MustPost( `mutation($id: Int!, $text: String!) { updateTodo(id: $id, changes:{text:$text}) { text } }`, &resp, - client.Var("id", 4), + client.Var("id", 5), client.Var("text", "Very important"), ) @@ -41,7 +41,7 @@ func TestTodo(t *testing.T) { Typename string `json:"__typename"` } } - c.MustPost(`{ todo(id: 4) { __typename } }`, &resp) + c.MustPost(`{ todo(id: 5) { __typename } }`, &resp) require.Equal(t, "Todo", resp.Todo.Typename) }) @@ -50,7 +50,7 @@ func TestTodo(t *testing.T) { var resp struct { UpdateTodo struct{ Text string } } - c.MustPost(`mutation { updateTodo(id: 4, changes:{done:true}) { text } }`, &resp) + c.MustPost(`mutation { updateTodo(id: 5, changes:{done:true}) { text } }`, &resp) require.Equal(t, "Very important", resp.UpdateTodo.Text) }) @@ -76,6 +76,19 @@ func TestTodo(t *testing.T) { require.Nil(t, resp.Todo) }) + t.Run("get done status of unowned todo", func(t *testing.T) { + var resp struct { + Todo *struct { + Text string + Done bool + } + } + err := c.Post(`{ todo(id:3) { text, done } }`, &resp) + + require.EqualError(t, err, `[{"message":"you dont own that","path":["todo","done"]}]`) + require.Nil(t, resp.Todo) + }) + t.Run("test panic", func(t *testing.T) { var resp struct { Todo *struct{ Text string } @@ -100,20 +113,19 @@ func TestTodo(t *testing.T) { Todos []struct { ID int Text string - Done bool } } c.MustPost(`{ todo(id:1) { id done text } lastTodo { id text done } - todos { id text done } + todos { id text } }`, &resp) require.Equal(t, 1, resp.Todo.ID) - require.Equal(t, 4, resp.LastTodo.ID) - require.Len(t, resp.Todos, 4) + require.Equal(t, 5, resp.LastTodo.ID) + require.Len(t, resp.Todos, 5) require.Equal(t, "Very important", resp.LastTodo.Text) - require.Equal(t, 4, resp.LastTodo.ID) + require.Equal(t, 5, resp.LastTodo.ID) }) t.Run("introspection", func(t *testing.T) { @@ -130,19 +142,6 @@ func TestTodo(t *testing.T) { require.Equal(t, "Completed todo", resp.CreateTodo.Text) }) - - t.Run("isAuthenticated directive middleware", func(t *testing.T) { - var resp map[string]interface{} - c.MustPost(`{ authenticatedTodo(id: 1) { __typename } }`, &resp) - val, ok := resp["authenticatedTodo"] - require.True(t, ok) - require.Nil(t, val) - - c.MustPost(`{ authenticatedTodo(id: 2) { __typename } }`, &resp) - val, ok = resp["authenticatedTodo"] - require.True(t, ok) - require.NotNil(t, val) - }) } func TestSkipAndIncludeDirectives(t *testing.T) { diff --git a/integration/generated.go b/integration/generated.go index f7802ec3f8b..1bbad672438 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -36,7 +36,7 @@ type ResolverRoot interface { } type DirectiveRoot struct { - Magic func(ctx context.Context, next graphql.Resolver, kind *int) (res interface{}, err error) + Magic func(ctx context.Context, obj interface{}, next graphql.Resolver, kind *int) (res interface{}, err error) } type ElementResolver interface { Child(ctx context.Context, obj *models.Element) (models.Element, error) @@ -150,7 +150,7 @@ func (ec *executionContext) _Element_child(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Element().Child(ctx, obj) }) if resTmp == nil { @@ -173,7 +173,7 @@ func (ec *executionContext) _Element_error(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Element().Error(ctx, obj) }) if resTmp == nil { @@ -195,7 +195,7 @@ func (ec *executionContext) _Element_mismatched(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Element().Mismatched(ctx, obj) }) if resTmp == nil { @@ -293,7 +293,7 @@ func (ec *executionContext) _Query_path(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Path(ctx) }) if resTmp == nil { @@ -340,7 +340,7 @@ func (ec *executionContext) _Query_date(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Date(ctx, args["filter"].(models.DateFilter)) }) if resTmp == nil { @@ -362,7 +362,7 @@ func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Viewer(ctx) }) if resTmp == nil { @@ -386,7 +386,7 @@ func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().JSONEncoding(ctx) }) if resTmp == nil { @@ -420,7 +420,7 @@ func (ec *executionContext) _Query_error(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Query().Error(ctx, args["type"].(models.ErrorType)) }) if resTmp == nil { @@ -454,7 +454,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) if resTmp == nil { @@ -478,7 +478,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) if resTmp == nil { @@ -542,7 +542,7 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -564,7 +564,7 @@ func (ec *executionContext) _User_likes(ctx context.Context, field graphql.Colle Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return ec.resolvers.User().Likes(ctx, obj) }) if resTmp == nil { @@ -619,7 +619,7 @@ func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.User, nil }) if resTmp == nil { @@ -685,7 +685,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -707,7 +707,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -726,7 +726,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) if resTmp == nil { @@ -754,7 +754,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -827,7 +827,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -849,7 +849,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -868,7 +868,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -890,7 +890,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -958,7 +958,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -980,7 +980,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -999,7 +999,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) if resTmp == nil { @@ -1033,7 +1033,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -1063,7 +1063,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) if resTmp == nil { @@ -1085,7 +1085,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) if resTmp == nil { @@ -1143,7 +1143,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) if resTmp == nil { @@ -1165,7 +1165,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) if resTmp == nil { @@ -1184,7 +1184,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) if resTmp == nil { @@ -1214,7 +1214,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) if resTmp == nil { @@ -1281,7 +1281,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) if resTmp == nil { @@ -1315,7 +1315,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) if resTmp == nil { @@ -1345,7 +1345,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) if resTmp == nil { @@ -1369,7 +1369,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) if resTmp == nil { @@ -1393,7 +1393,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) if resTmp == nil { @@ -1473,7 +1473,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) if resTmp == nil { @@ -1495,7 +1495,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) if resTmp == nil { @@ -1518,7 +1518,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) if resTmp == nil { @@ -1549,7 +1549,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1580,7 +1580,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) if resTmp == nil { @@ -1611,7 +1611,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) if resTmp == nil { @@ -1654,7 +1654,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { @@ -1685,7 +1685,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) if resTmp == nil { @@ -1716,7 +1716,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) if resTmp == nil { @@ -1779,7 +1779,7 @@ func UnmarshalDateFilter(v interface{}) (models.DateFilter, error) { return it, nil } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1810,7 +1810,7 @@ func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Re args["kind"] = arg0 n := next next = func(ctx context.Context) (interface{}, error) { - return ec.directives.Magic(ctx, n, args["kind"].(*int)) + return ec.directives.Magic(ctx, obj, n, args["kind"].(*int)) } } }