diff --git a/codegen/object.go b/codegen/object.go index 262dccc91be..ef44f2f7433 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -70,6 +70,15 @@ func (o *Object) HasResolvers() bool { return false } +func (o *Object) IsConcurrent() bool { + for _, f := range o.Fields { + if f.IsConcurrent() { + return true + } + } + return false +} + func (f *Field) IsResolver() bool { return f.GoFieldName == "" } diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 45b5f6d0adb..eb9f2e1beb1 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -2,12 +2,12 @@ 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{Field: field})\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\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\n\t\t{{- if $field.IsConcurrent }}\n\t\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\t\tArgs: {{if $field.Args }}args{{else}}nil{{end}},\n\t\t\t\tField: field,\n\t\t\t})\n\t\t\treturn graphql.Defer(func() (ret graphql.Marshaler) {\n\t\t\t\tdefer func() {\n\t\t\t\t\tif r := recover(); r != nil {\n\t\t\t\t\t\tuserErr := ec.Recover(ctx, r)\n\t\t\t\t\t\tec.Error(ctx, userErr)\n\t\t\t\t\t\tret = graphql.Null\n\t\t\t\t\t}\n\t\t\t\t}()\n\t\t{{ else }}\n\t\t\trctx := graphql.GetResolverContext(ctx)\n\t\t\trctx.Object = {{$object.GQLType|quote}}\n\t\t\trctx.Args = {{if $field.Args }}args{{else}}nil{{end}}\n\t\t\trctx.Field = field\n\t\t\trctx.PushField(field.Alias)\n\t\t\tdefer rctx.Pop()\n\t\t{{- end }}\n\t\t\tresTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) {\n\t\t\t\t{{- if $field.IsResolver }}\n\t\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t\t{{- else }}\n\t\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t\t{{- end }}\n\t\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t\t{{- end }}\n\t\t\t})\n\t\t\tif resTmp == nil {\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\tres := resTmp.({{$field.Signature}})\n\t\t\t{{ $field.WriteJson }}\n\t\t{{- if $field.IsConcurrent }}\n\t\t\t})\n\t\t{{- end }}\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) interface{} {\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{Field: field})\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\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\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\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", "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", - "object.gotpl": "{{ $object := . }}\n\nvar {{ $object.GQLType|lcFirst}}Implementors = {{$object.Implementors}}\n\n// nolint: gocyclo, errcheck, gas, goconst\n{{- if .Stream }}\nfunc (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.GQLType|lcFirst}}Implementors)\n\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\tObject: {{$object.GQLType|quote}},\n\t})\n\tif len(fields) != 1 {\n\t\tec.Errorf(ctx, \"must subscribe to exactly one stream\")\n\t\treturn nil\n\t}\n\n\tswitch fields[0].Name {\n\t{{- range $field := $object.Fields }}\n\tcase \"{{$field.GQLName}}\":\n\t\treturn ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, fields[0])\n\t{{- end }}\n\tdefault:\n\t\tpanic(\"unknown field \" + strconv.Quote(fields[0].Name))\n\t}\n}\n{{- else }}\nfunc (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.FullName}} {{end}}) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.GQLType|lcFirst}}Implementors)\n\t{{if $object.Root}}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t})\n\t{{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString({{$object.GQLType|quote}})\n\t\t{{- range $field := $object.Fields }}\n\t\tcase \"{{$field.GQLName}}\":\n\t\t\tout.Values[i] = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t{{- end }}\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\n\treturn out\n}\n{{- end }}\n", + "object.gotpl": "{{ $object := . }}\n\nvar {{ $object.GQLType|lcFirst}}Implementors = {{$object.Implementors}}\n\n// nolint: gocyclo, errcheck, gas, goconst\n{{- if .Stream }}\nfunc (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.GQLType|lcFirst}}Implementors)\n\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\tObject: {{$object.GQLType|quote}},\n\t})\n\tif len(fields) != 1 {\n\t\tec.Errorf(ctx, \"must subscribe to exactly one stream\")\n\t\treturn nil\n\t}\n\n\tswitch fields[0].Name {\n\t{{- range $field := $object.Fields }}\n\tcase \"{{$field.GQLName}}\":\n\t\treturn ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, fields[0])\n\t{{- end }}\n\tdefault:\n\t\tpanic(\"unknown field \" + strconv.Quote(fields[0].Name))\n\t}\n}\n{{- else }}\nfunc (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.FullName}} {{end}}) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.GQLType|lcFirst}}Implementors)\n\t{{if $object.Root}}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t})\n\t{{end}}\n\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString({{$object.GQLType|quote}})\n\t\t{{- range $field := $object.Fields }}\n\t\tcase \"{{$field.GQLName}}\":\n\t\t\t{{- if $field.IsConcurrent }}\n\t\t\t\twg.Add(1)\n\t\t\t\tgo func(i int, field graphql.CollectedField) {\n\t\t\t{{- end }}\n\t\t\t\tout.Values[i] = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t{{- if $field.IsConcurrent }}\n\t\t\t\t\twg.Done()\n\t\t\t\t}(i, field)\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\t{{if $object.IsConcurrent}} wg.Wait() {{end}}\n\treturn out\n}\n{{- end }}\n", "resolver.gotpl": "//go:generate gorunpkg github.com/99designs/gqlgen\n\npackage {{ .PackageName }}\n\nimport (\n{{- range $import := .Imports }}\n\t{{- $import.Write }}\n{{ end }}\n)\n\ntype {{.ResolverType}} struct {}\n\n{{ range $object := .Objects -}}\n\t{{- if $object.HasResolvers -}}\n\t\tfunc (r *{{$.ResolverType}}) {{$object.GQLType}}() {{ $object.ResolverInterface.FullName }} {\n\t\t\treturn &{{lcFirst $object.GQLType}}Resolver{r}\n\t\t}\n\t{{ end -}}\n{{ end }}\n\n{{ range $object := .Objects -}}\n\t{{- if $object.HasResolvers -}}\n\t\ttype {{lcFirst $object.GQLType}}Resolver struct { *Resolver }\n\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{- if $field.IsResolver -}}\n\t\t\tfunc (r *{{lcFirst $object.GQLType}}Resolver) {{ $field.ShortResolverDeclaration }} {\n\t\t\t\tpanic(\"not implemented\")\n\t\t\t}\n\t\t\t{{ end -}}\n\t\t{{ end -}}\n\t{{ end -}}\n{{ end }}\n", "server.gotpl": "package main\n\nimport (\n{{- range $import := .Imports }}\n\t{{- $import.Write }}\n{{ end }}\n)\n\nconst defaultPort = \"8080\"\n\nfunc main() {\n\tport := os.Getenv(\"PORT\")\n\tif port == \"\" {\n\t\tport = defaultPort\n\t}\n\n\thttp.Handle(\"/\", handler.Playground(\"GraphQL playground\", \"/query\"))\n\thttp.Handle(\"/query\", handler.GraphQL({{.ExecPackageName}}.NewExecutableSchema({{.ExecPackageName}}.Config{Resolvers: &{{.ResolverPackageName}}.Resolver{}})))\n\n\tlog.Printf(\"connect to http://localhost:%s/ for GraphQL playground\", port)\n\tlog.Fatal(http.ListenAndServe(\":\" + port, nil))\n}\n", } diff --git a/codegen/templates/field.gotpl b/codegen/templates/field.gotpl index c324a4ecddf..d46c87add38 100644 --- a/codegen/templates/field.gotpl +++ b/codegen/templates/field.gotpl @@ -29,49 +29,29 @@ rawArgs := field.ArgumentMap(ec.Variables) {{ template "args.gotpl" $field.Args }} {{- end }} - - {{- if $field.IsConcurrent }} - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: {{$object.GQLType|quote}}, - Args: {{if $field.Args }}args{{else}}nil{{end}}, - Field: field, - }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - {{ else }} - rctx := graphql.GetResolverContext(ctx) - rctx.Object = {{$object.GQLType|quote}} - rctx.Args = {{if $field.Args }}args{{else}}nil{{end}} - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() - {{- end }} - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - {{- if $field.IsResolver }} - return ec.resolvers.{{ $field.ShortInvocation }} - {{- else if $field.IsMethod }} - {{- if $field.NoErr }} - return {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil - {{- else }} - return {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}) - {{- end }} - {{- else if $field.IsVariable }} - return {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil + rctx := &graphql.ResolverContext{ + Object: {{$object.GQLType|quote}}, + Args: {{if $field.Args }}args{{else}}nil{{end}}, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + {{- if $field.IsResolver }} + return ec.resolvers.{{ $field.ShortInvocation }} + {{- else if $field.IsMethod }} + {{- if $field.NoErr }} + return {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil + {{- else }} + return {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}) {{- end }} - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.({{$field.Signature}}) - {{ $field.WriteJson }} - {{- if $field.IsConcurrent }} - }) - {{- end }} + {{- else if $field.IsVariable }} + return {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil + {{- end }} + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.({{$field.Signature}}) + {{ $field.WriteJson }} } {{ end }} diff --git a/codegen/templates/generated.gotpl b/codegen/templates/generated.gotpl index 309185dd8fe..c6b093db6e3 100644 --- a/codegen/templates/generated.gotpl +++ b/codegen/templates/generated.gotpl @@ -147,7 +147,13 @@ type executionContext struct { {{ template "input.gotpl" $input }} {{- end }} -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) interface{} { +func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() {{- if .Directives }} rctx := graphql.GetResolverContext(ctx) for _, d := range rctx.Field.Definition.Directives { diff --git a/codegen/templates/object.gotpl b/codegen/templates/object.gotpl index 9535a65a6d6..62081b331df 100644 --- a/codegen/templates/object.gotpl +++ b/codegen/templates/object.gotpl @@ -31,6 +31,8 @@ func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.Se Object: {{$object.GQLType|quote}}, }) {{end}} + + {{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}} out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -40,13 +42,21 @@ func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.Se out.Values[i] = graphql.MarshalString({{$object.GQLType|quote}}) {{- range $field := $object.Fields }} case "{{$field.GQLName}}": - out.Values[i] = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) + {{- if $field.IsConcurrent }} + wg.Add(1) + go func(i int, field graphql.CollectedField) { + {{- end }} + out.Values[i] = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) + {{- if $field.IsConcurrent }} + wg.Done() + }(i, field) + {{- end }} {{- end }} default: panic("unknown field " + strconv.Quote(field.Name)) } } - + {{if $object.IsConcurrent}} wg.Wait() {{end}} return out } {{- end }} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index a7097c1b277..293bba0719e 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -7,6 +7,7 @@ import ( context "context" fmt "fmt" strconv "strconv" + sync "sync" introspection1 "github.com/99designs/gqlgen/codegen/testserver/introspection" invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename" @@ -115,12 +116,12 @@ func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, o } func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Circle" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Circle", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Radius, nil }) @@ -132,12 +133,12 @@ func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.Co } func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Circle" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Circle", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Area(), nil }) @@ -154,6 +155,7 @@ var forcedResolverImplementors = []string{"ForcedResolver"} func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.SelectionSet, obj *ForcedResolver) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, forcedResolverImplementors) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -162,42 +164,37 @@ func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.Selecti case "__typename": out.Values[i] = graphql.MarshalString("ForcedResolver") case "field": - out.Values[i] = ec._ForcedResolver_field(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._ForcedResolver_field(ctx, field, obj) + wg.Done() + }(i, field) default: panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "ForcedResolver", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.ForcedResolver().Field(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.ForcedResolver().Field(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Circle) - if res == nil { - return graphql.Null - } - return ec._Circle(ctx, field.Selections, res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Circle) + if res == nil { + return graphql.Null + } + return ec._Circle(ctx, field.Selections, res) } var innerObjectImplementors = []string{"InnerObject"} @@ -224,12 +221,12 @@ func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "InnerObject" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "InnerObject", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -264,12 +261,12 @@ func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.Sele } func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "InvalidIdentifier" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "InvalidIdentifier", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -304,12 +301,12 @@ func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj * } func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection1.It) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "It" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "It", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -344,12 +341,12 @@ func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "OuterObject" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "OuterObject", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Inner, nil }) @@ -370,6 +367,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -378,23 +376,59 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "__typename": out.Values[i] = graphql.MarshalString("Query") case "invalidIdentifier": - out.Values[i] = ec._Query_invalidIdentifier(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_invalidIdentifier(ctx, field) + wg.Done() + }(i, field) case "collision": - out.Values[i] = ec._Query_collision(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_collision(ctx, field) + wg.Done() + }(i, field) case "mapInput": - out.Values[i] = ec._Query_mapInput(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_mapInput(ctx, field) + wg.Done() + }(i, field) case "recursive": - out.Values[i] = ec._Query_recursive(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_recursive(ctx, field) + wg.Done() + }(i, field) case "nestedInputs": - out.Values[i] = ec._Query_nestedInputs(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_nestedInputs(ctx, field) + wg.Done() + }(i, field) case "nestedOutputs": - out.Values[i] = ec._Query_nestedOutputs(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_nestedOutputs(ctx, field) + wg.Done() + }(i, field) case "keywords": - out.Values[i] = ec._Query_keywords(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_keywords(ctx, field) + wg.Done() + }(i, field) case "shapes": - out.Values[i] = ec._Query_shapes(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_shapes(ctx, field) + wg.Done() + }(i, field) case "keywordArgs": - out.Values[i] = ec._Query_keywordArgs(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_keywordArgs(ctx, field) + wg.Done() + }(i, field) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -403,66 +437,48 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().InvalidIdentifier(ctx) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().InvalidIdentifier(ctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*invalid_packagename.InvalidIdentifier) - if res == nil { - return graphql.Null - } - return ec._InvalidIdentifier(ctx, field.Selections, res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*invalid_packagename.InvalidIdentifier) + if res == nil { + return graphql.Null + } + return ec._InvalidIdentifier(ctx, field.Selections, res) } func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Collision(ctx) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Collision(ctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection1.It) - if res == nil { - return graphql.Null - } - return ec._It(ctx, field.Selections, res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection1.It) + if res == nil { + return graphql.Null + } + return ec._It(ctx, field.Selections, res) } func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -483,32 +499,23 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C } } args["input"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().MapInput(ctx, args["input"].(*map[string]interface{})) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().MapInput(ctx, args["input"].(*map[string]interface{})) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*bool) - if res == nil { - return graphql.Null - } - return graphql.MarshalBoolean(*res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + if res == nil { + return graphql.Null + } + return graphql.MarshalBoolean(*res) } func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -529,32 +536,23 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql. } } args["input"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Recursive(ctx, args["input"].(*RecursiveInputSlice)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Recursive(ctx, args["input"].(*RecursiveInputSlice)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*bool) - if res == nil { - return graphql.Null - } - return graphql.MarshalBoolean(*res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + if res == nil { + return graphql.Null + } + return graphql.MarshalBoolean(*res) } func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -596,79 +594,61 @@ func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graph } } args["input"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().NestedInputs(ctx, args["input"].([][]*OuterInput)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().NestedInputs(ctx, args["input"].([][]*OuterInput)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*bool) - if res == nil { - return graphql.Null - } - return graphql.MarshalBoolean(*res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + if res == nil { + return graphql.Null + } + return graphql.MarshalBoolean(*res) } func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().NestedOutputs(ctx) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null + if resTmp == nil { + return graphql.Null + } + res := resTmp.([][]*OuterObject) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + arr2 := graphql.Array{} + for idx2 := range res[idx1] { + arr2 = append(arr2, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx2) + defer rctx.Pop() + if res[idx1][idx2] == nil { + return graphql.Null + } + return ec._OuterObject(ctx, field.Selections, res[idx1][idx2]) + }()) } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().NestedOutputs(ctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([][]*OuterObject) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - arr2 := graphql.Array{} - for idx2 := range res[idx1] { - arr2 = append(arr2, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx2) - defer rctx.Pop() - if res[idx1][idx2] == nil { - return graphql.Null - } - return ec._OuterObject(ctx, field.Selections, res[idx1][idx2]) - }()) - } - return arr2 - }()) - } - return arr1 - }) + return arr2 + }()) + } + return arr1 } func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -689,67 +669,49 @@ func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.C } } args["input"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Keywords(ctx, args["input"].(*Keywords)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Keywords(ctx, args["input"].(*Keywords)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(bool) - return graphql.MarshalBoolean(res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(bool) + return graphql.MarshalBoolean(res) } func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Shapes(ctx) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*Shape) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + if res[idx1] == nil { + return graphql.Null } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Shapes(ctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*Shape) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - if res[idx1] == nil { - return graphql.Null - } - return ec._Shape(ctx, field.Selections, res[idx1]) - }()) - } - return arr1 - }) + return ec._Shape(ctx, field.Selections, res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1005,29 +967,20 @@ func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphq } } args["var"] = arg24 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, 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)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, 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 { - return graphql.Null - } - res := resTmp.(bool) - return graphql.MarshalBoolean(res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(bool) + return graphql.MarshalBoolean(res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1043,12 +996,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } } args["name"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) @@ -1063,12 +1016,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) @@ -1110,12 +1063,12 @@ func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet } func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Rectangle" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Rectangle", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Length, nil }) @@ -1127,12 +1080,12 @@ func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql } func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Rectangle" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Rectangle", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Width, nil }) @@ -1144,12 +1097,12 @@ func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql. } func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Rectangle" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Rectangle", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Area(), nil }) @@ -1190,12 +1143,12 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -1207,12 +1160,12 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -1224,12 +1177,12 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) @@ -1250,12 +1203,12 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -1305,12 +1258,12 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -1322,12 +1275,12 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -1339,12 +1292,12 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -1356,12 +1309,12 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -1406,12 +1359,12 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -1423,12 +1376,12 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -1440,12 +1393,12 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -1466,12 +1419,12 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -1486,12 +1439,12 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -1503,12 +1456,12 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -1549,12 +1502,12 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -1566,12 +1519,12 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -1583,12 +1536,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -1603,12 +1556,12 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) @@ -1654,12 +1607,12 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) @@ -1680,12 +1633,12 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) @@ -1700,12 +1653,12 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) @@ -1720,12 +1673,12 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) @@ -1740,12 +1693,12 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) @@ -1805,12 +1758,12 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) @@ -1822,12 +1775,12 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) @@ -1842,12 +1795,12 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) @@ -1871,12 +1824,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) @@ -1897,12 +1850,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) @@ -1923,12 +1876,12 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) @@ -1961,12 +1914,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) @@ -1987,12 +1940,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) @@ -2013,12 +1966,12 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) @@ -2285,7 +2238,13 @@ func UnmarshalRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { return it, nil } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) interface{} { +func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() res, err := ec.ResolverMiddleware(ctx, next) if err != nil { ec.Error(ctx, err) diff --git a/example/chat/generated.go b/example/chat/generated.go index e4069cfe1ee..3b396fab92e 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -6,6 +6,7 @@ import ( "bytes" context "context" strconv "strconv" + sync "sync" time "time" graphql "github.com/99designs/gqlgen/graphql" @@ -145,12 +146,12 @@ func (ec *executionContext) _Chatroom(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.CollectedField, obj *Chatroom) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Chatroom" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Chatroom", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -162,12 +163,12 @@ func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.Co } func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphql.CollectedField, obj *Chatroom) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Chatroom" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Chatroom", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Messages, nil }) @@ -217,12 +218,12 @@ func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) _Message_id(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Message" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Message", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -234,12 +235,12 @@ func (ec *executionContext) _Message_id(ctx context.Context, field graphql.Colle } func (ec *executionContext) _Message_text(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Message" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Message", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Text, nil }) @@ -251,12 +252,12 @@ func (ec *executionContext) _Message_text(ctx context.Context, field graphql.Col } func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Message" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Message", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.CreatedBy, nil }) @@ -268,12 +269,12 @@ func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphq } func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Message" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Message", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.CreatedAt, nil }) @@ -344,12 +345,12 @@ func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.Co } } args["roomName"] = arg2 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Mutation" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Mutation", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Mutation().Post(ctx, args["text"].(string), args["username"].(string), args["roomName"].(string)) }) @@ -370,6 +371,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -378,7 +380,11 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "__typename": out.Values[i] = graphql.MarshalString("Query") case "room": - out.Values[i] = ec._Query_room(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_room(ctx, field) + wg.Done() + }(i, field) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -387,7 +393,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } @@ -404,32 +410,23 @@ func (ec *executionContext) _Query_room(ctx context.Context, field graphql.Colle } } args["name"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Room(ctx, args["name"].(string)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Room(ctx, args["name"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Chatroom) - if res == nil { - return graphql.Null - } - return ec._Chatroom(ctx, field.Selections, res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Chatroom) + if res == nil { + return graphql.Null + } + return ec._Chatroom(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -445,12 +442,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } } args["name"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) @@ -465,12 +462,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) @@ -565,12 +562,12 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -582,12 +579,12 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -599,12 +596,12 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) @@ -625,12 +622,12 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -680,12 +677,12 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -697,12 +694,12 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -714,12 +711,12 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -731,12 +728,12 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -781,12 +778,12 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -798,12 +795,12 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -815,12 +812,12 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -841,12 +838,12 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -861,12 +858,12 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -878,12 +875,12 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -924,12 +921,12 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -941,12 +938,12 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -958,12 +955,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -978,12 +975,12 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) @@ -1029,12 +1026,12 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) @@ -1055,12 +1052,12 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) @@ -1075,12 +1072,12 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) @@ -1095,12 +1092,12 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) @@ -1115,12 +1112,12 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) @@ -1180,12 +1177,12 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) @@ -1197,12 +1194,12 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) @@ -1217,12 +1214,12 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) @@ -1246,12 +1243,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) @@ -1272,12 +1269,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) @@ -1298,12 +1295,12 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) @@ -1336,12 +1333,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) @@ -1362,12 +1359,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) @@ -1388,12 +1385,12 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) @@ -1407,7 +1404,13 @@ 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) interface{} { +func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() res, err := ec.ResolverMiddleware(ctx, next) if err != nil { ec.Error(ctx, err) diff --git a/example/config/generated.go b/example/config/generated.go index 6faad44bcc2..cb2e75e8b67 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -6,6 +6,7 @@ import ( "bytes" context "context" strconv "strconv" + sync "sync" graphql "github.com/99designs/gqlgen/graphql" introspection "github.com/99designs/gqlgen/graphql/introspection" @@ -134,12 +135,12 @@ func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field grap } } args["input"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Mutation" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Mutation", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Mutation().CreateTodo(ctx, args["input"].(NewTodo)) }) @@ -160,6 +161,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -168,7 +170,11 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "__typename": out.Values[i] = graphql.MarshalString("Query") case "todos": - out.Values[i] = ec._Query_todos(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_todos(ctx, field) + wg.Done() + }(i, field) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -177,43 +183,34 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Todos(ctx) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Todos(ctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Todo) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._Todo(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Todo) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._Todo(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -229,12 +226,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } } args["name"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) @@ -249,12 +246,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) @@ -274,6 +271,7 @@ var todoImplementors = []string{"Todo"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, todoImplementors) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -282,7 +280,11 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "id": - out.Values[i] = ec._Todo_id(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Todo_id(ctx, field, obj) + wg.Done() + }(i, field) case "databaseId": out.Values[i] = ec._Todo_databaseId(ctx, field, obj) case "text": @@ -295,43 +297,34 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Todo", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Todo().ID(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Todo().ID(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - return graphql.MarshalID(res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalID(res) } func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Todo" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DatabaseID, nil }) @@ -343,12 +336,12 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Todo" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -360,12 +353,12 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec } func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Todo" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Done, nil }) @@ -377,12 +370,12 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec } func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Todo" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.User, nil }) @@ -419,12 +412,12 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "User" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "User", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -436,12 +429,12 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "User" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "User", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.FullName(), nil }) @@ -482,12 +475,12 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -499,12 +492,12 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -516,12 +509,12 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) @@ -542,12 +535,12 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -597,12 +590,12 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -614,12 +607,12 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -631,12 +624,12 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -648,12 +641,12 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -698,12 +691,12 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -715,12 +708,12 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -732,12 +725,12 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -758,12 +751,12 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -778,12 +771,12 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -795,12 +788,12 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -841,12 +834,12 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -858,12 +851,12 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -875,12 +868,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -895,12 +888,12 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) @@ -946,12 +939,12 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) @@ -972,12 +965,12 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) @@ -992,12 +985,12 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) @@ -1012,12 +1005,12 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) @@ -1032,12 +1025,12 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) @@ -1097,12 +1090,12 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) @@ -1114,12 +1107,12 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) @@ -1134,12 +1127,12 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) @@ -1163,12 +1156,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) @@ -1189,12 +1182,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) @@ -1215,12 +1208,12 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) @@ -1253,12 +1246,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) @@ -1279,12 +1272,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) @@ -1305,12 +1298,12 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) @@ -1348,7 +1341,13 @@ func UnmarshalNewTodo(v interface{}) (NewTodo, error) { return it, nil } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) interface{} { +func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() res, err := ec.ResolverMiddleware(ctx, next) if err != nil { ec.Error(ctx, err) diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index c25b373e803..5c5c7e33d3a 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -6,6 +6,7 @@ import ( "bytes" context "context" strconv "strconv" + sync "sync" time "time" graphql "github.com/99designs/gqlgen/graphql" @@ -114,12 +115,12 @@ func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) _Address_id(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Address" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Address", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -131,12 +132,12 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle } func (ec *executionContext) _Address_street(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Address" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Address", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Street, nil }) @@ -148,12 +149,12 @@ func (ec *executionContext) _Address_street(ctx context.Context, field graphql.C } func (ec *executionContext) _Address_country(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Address" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Address", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Country, nil }) @@ -170,6 +171,7 @@ var customerImplementors = []string{"Customer"} func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, obj *Customer) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, customerImplementors) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -182,24 +184,32 @@ func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, case "name": out.Values[i] = ec._Customer_name(ctx, field, obj) case "address": - out.Values[i] = ec._Customer_address(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Customer_address(ctx, field, obj) + wg.Done() + }(i, field) case "orders": - out.Values[i] = ec._Customer_orders(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Customer_orders(ctx, field, obj) + wg.Done() + }(i, field) default: panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Customer" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Customer", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -211,12 +221,12 @@ func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.Coll } func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Customer" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Customer", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -228,67 +238,49 @@ func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.Co } func (ec *executionContext) _Customer_address(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Customer", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Customer().Address(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Customer().Address(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Address) - if res == nil { - return graphql.Null - } - return ec._Address(ctx, field.Selections, res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Address) + if res == nil { + return graphql.Null + } + return ec._Address(ctx, field.Selections, res) } func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Customer", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Customer().Orders(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Customer().Orders(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Order) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._Order(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Order) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._Order(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } var itemImplementors = []string{"Item"} @@ -315,12 +307,12 @@ func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj } func (ec *executionContext) _Item_name(ctx context.Context, field graphql.CollectedField, obj *Item) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Item" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Item", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -337,6 +329,7 @@ var orderImplementors = []string{"Order"} func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, obj *Order) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, orderImplementors) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -351,22 +344,26 @@ func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, ob case "amount": out.Values[i] = ec._Order_amount(ctx, field, obj) case "items": - out.Values[i] = ec._Order_items(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Order_items(ctx, field, obj) + wg.Done() + }(i, field) default: panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _Order_id(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Order" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Order", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -378,12 +375,12 @@ func (ec *executionContext) _Order_id(ctx context.Context, field graphql.Collect } func (ec *executionContext) _Order_date(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Order" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Order", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Date, nil }) @@ -395,12 +392,12 @@ func (ec *executionContext) _Order_date(ctx context.Context, field graphql.Colle } func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Order" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Order", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Amount, nil }) @@ -412,38 +409,29 @@ func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.Col } func (ec *executionContext) _Order_items(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Order", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Order().Items(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Order().Items(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Item) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._Item(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Item) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._Item(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } var queryImplementors = []string{"Query"} @@ -456,6 +444,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -464,11 +453,23 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "__typename": out.Values[i] = graphql.MarshalString("Query") case "customers": - out.Values[i] = ec._Query_customers(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_customers(ctx, field) + wg.Done() + }(i, field) case "torture1d": - out.Values[i] = ec._Query_torture1d(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_torture1d(ctx, field) + wg.Done() + }(i, field) case "torture2d": - out.Values[i] = ec._Query_torture2d(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_torture2d(ctx, field) + wg.Done() + }(i, field) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -477,43 +478,34 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _Query_customers(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Customers(ctx) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Customers(ctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Customer) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._Customer(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Customer) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._Customer(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -540,38 +532,29 @@ func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql. } } args["customerIds"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Torture1d(ctx, args["customerIds"].([]int)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Torture1d(ctx, args["customerIds"].([]int)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Customer) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._Customer(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Customer) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._Customer(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -609,47 +592,38 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. } } args["customerIds"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Torture2d(ctx, args["customerIds"].([][]int)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null + if resTmp == nil { + return graphql.Null + } + res := resTmp.([][]Customer) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + arr2 := graphql.Array{} + for idx2 := range res[idx1] { + arr2 = append(arr2, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx2) + defer rctx.Pop() + return ec._Customer(ctx, field.Selections, &res[idx1][idx2]) + }()) } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Torture2d(ctx, args["customerIds"].([][]int)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([][]Customer) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - arr2 := graphql.Array{} - for idx2 := range res[idx1] { - arr2 = append(arr2, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx2) - defer rctx.Pop() - return ec._Customer(ctx, field.Selections, &res[idx1][idx2]) - }()) - } - return arr2 - }()) - } - return arr1 - }) + return arr2 + }()) + } + return arr1 } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -665,12 +639,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } } args["name"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) @@ -685,12 +659,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) @@ -734,12 +708,12 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -751,12 +725,12 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -768,12 +742,12 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) @@ -794,12 +768,12 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -849,12 +823,12 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -866,12 +840,12 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -883,12 +857,12 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -900,12 +874,12 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -950,12 +924,12 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -967,12 +941,12 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -984,12 +958,12 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -1010,12 +984,12 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -1030,12 +1004,12 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -1047,12 +1021,12 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -1093,12 +1067,12 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -1110,12 +1084,12 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -1127,12 +1101,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -1147,12 +1121,12 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) @@ -1198,12 +1172,12 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) @@ -1224,12 +1198,12 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) @@ -1244,12 +1218,12 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) @@ -1264,12 +1238,12 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) @@ -1284,12 +1258,12 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) @@ -1349,12 +1323,12 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) @@ -1366,12 +1340,12 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) @@ -1386,12 +1360,12 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) @@ -1415,12 +1389,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) @@ -1441,12 +1415,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) @@ -1467,12 +1441,12 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) @@ -1505,12 +1479,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) @@ -1531,12 +1505,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) @@ -1557,12 +1531,12 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) @@ -1576,7 +1550,13 @@ 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) interface{} { +func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() res, err := ec.ResolverMiddleware(ctx, next) if err != nil { ec.Error(ctx, err) diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 81e207c6bc4..dd75719736e 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -7,6 +7,7 @@ import ( context "context" external "external" strconv "strconv" + sync "sync" time "time" model "github.com/99designs/gqlgen/example/scalars/model" @@ -109,12 +110,12 @@ func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) _Address_id(ctx context.Context, field graphql.CollectedField, obj *model.Address) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Address" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Address", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -126,12 +127,12 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle } func (ec *executionContext) _Address_location(ctx context.Context, field graphql.CollectedField, obj *model.Address) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Address" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Address", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Location, nil }) @@ -155,6 +156,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -163,9 +165,17 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "__typename": out.Values[i] = graphql.MarshalString("Query") case "user": - out.Values[i] = ec._Query_user(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_user(ctx, field) + wg.Done() + }(i, field) case "search": - out.Values[i] = ec._Query_search(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_search(ctx, field) + wg.Done() + }(i, field) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -174,7 +184,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } @@ -191,32 +201,23 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle } } args["id"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().User(ctx, args["id"].(external.ObjectID)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().User(ctx, args["id"].(external.ObjectID)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*model.User) - if res == nil { - return graphql.Null - } - return ec._User(ctx, field.Selections, res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.User) + if res == nil { + return graphql.Null + } + return ec._User(ctx, field.Selections, res) } func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -232,38 +233,29 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col } } args["input"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Search(ctx, args["input"].(model.SearchArgs)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Search(ctx, args["input"].(model.SearchArgs)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]model.User) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._User(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]model.User) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._User(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -279,12 +271,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } } args["name"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) @@ -299,12 +291,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) @@ -324,6 +316,7 @@ var userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, userImplementors) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -340,9 +333,17 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj case "isBanned": out.Values[i] = ec._User_isBanned(ctx, field, obj) case "primitiveResolver": - out.Values[i] = ec._User_primitiveResolver(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._User_primitiveResolver(ctx, field, obj) + wg.Done() + }(i, field) case "customResolver": - out.Values[i] = ec._User_customResolver(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._User_customResolver(ctx, field, obj) + wg.Done() + }(i, field) case "address": out.Values[i] = ec._User_address(ctx, field, obj) case "tier": @@ -351,17 +352,17 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "User" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "User", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -373,12 +374,12 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "User" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "User", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -390,12 +391,12 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec } func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "User" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "User", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Created, nil }) @@ -407,12 +408,12 @@ func (ec *executionContext) _User_created(ctx context.Context, field graphql.Col } func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "User" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "User", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsBanned, nil }) @@ -424,64 +425,46 @@ func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.Co } func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "User", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.User().PrimitiveResolver(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.User().PrimitiveResolver(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - return graphql.MarshalString(res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) } func (ec *executionContext) _User_customResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "User", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.User().CustomResolver(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.User().CustomResolver(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(model.Point) - return res - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(model.Point) + return res } func (ec *executionContext) _User_address(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "User" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "User", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Address, nil }) @@ -493,12 +476,12 @@ func (ec *executionContext) _User_address(ctx context.Context, field graphql.Col } func (ec *executionContext) _User_tier(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "User" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "User", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Tier, nil }) @@ -539,12 +522,12 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -556,12 +539,12 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -573,12 +556,12 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) @@ -599,12 +582,12 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -654,12 +637,12 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -671,12 +654,12 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -688,12 +671,12 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -705,12 +688,12 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -755,12 +738,12 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -772,12 +755,12 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -789,12 +772,12 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -815,12 +798,12 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -835,12 +818,12 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -852,12 +835,12 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -898,12 +881,12 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -915,12 +898,12 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -932,12 +915,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -952,12 +935,12 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) @@ -1003,12 +986,12 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) @@ -1029,12 +1012,12 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) @@ -1049,12 +1032,12 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) @@ -1069,12 +1052,12 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) @@ -1089,12 +1072,12 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) @@ -1154,12 +1137,12 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) @@ -1171,12 +1154,12 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) @@ -1191,12 +1174,12 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) @@ -1220,12 +1203,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) @@ -1246,12 +1229,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) @@ -1272,12 +1255,12 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) @@ -1310,12 +1293,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) @@ -1336,12 +1319,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) @@ -1362,12 +1345,12 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) @@ -1424,7 +1407,13 @@ func UnmarshalSearchArgs(v interface{}) (model.SearchArgs, error) { return it, nil } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) interface{} { +func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() res, err := ec.ResolverMiddleware(ctx, next) if err != nil { ec.Error(ctx, err) diff --git a/example/selection/generated.go b/example/selection/generated.go index 71a7e7c860c..e8d19b1c53a 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -7,6 +7,7 @@ import ( context "context" fmt "fmt" strconv "strconv" + sync "sync" time "time" graphql "github.com/99designs/gqlgen/graphql" @@ -106,12 +107,12 @@ func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj } func (ec *executionContext) _Like_reaction(ctx context.Context, field graphql.CollectedField, obj *Like) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Like" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Like", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Reaction, nil }) @@ -123,12 +124,12 @@ func (ec *executionContext) _Like_reaction(ctx context.Context, field graphql.Co } func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.CollectedField, obj *Like) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Like" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Like", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Sent, nil }) @@ -140,12 +141,12 @@ func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.Collec } func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.CollectedField, obj *Like) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Like" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Like", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Selection, nil }) @@ -166,12 +167,12 @@ func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.C } func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.CollectedField, obj *Like) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Like" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Like", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Collected, nil }) @@ -221,12 +222,12 @@ func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj } func (ec *executionContext) _Post_message(ctx context.Context, field graphql.CollectedField, obj *Post) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Post" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Post", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Message, nil }) @@ -238,12 +239,12 @@ func (ec *executionContext) _Post_message(ctx context.Context, field graphql.Col } func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.CollectedField, obj *Post) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Post" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Post", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Sent, nil }) @@ -255,12 +256,12 @@ func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.Collec } func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.CollectedField, obj *Post) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Post" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Post", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Selection, nil }) @@ -281,12 +282,12 @@ func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.C } func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.CollectedField, obj *Post) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Post" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Post", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Collected, nil }) @@ -316,6 +317,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -324,7 +326,11 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "__typename": out.Values[i] = graphql.MarshalString("Query") case "events": - out.Values[i] = ec._Query_events(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_events(ctx, field) + wg.Done() + }(i, field) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -333,43 +339,34 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _Query_events(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Events(ctx) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Events(ctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Event) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._Event(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Event) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._Event(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -385,12 +382,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } } args["name"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) @@ -405,12 +402,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) @@ -454,12 +451,12 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -471,12 +468,12 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -488,12 +485,12 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) @@ -514,12 +511,12 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -569,12 +566,12 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -586,12 +583,12 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -603,12 +600,12 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -620,12 +617,12 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -670,12 +667,12 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -687,12 +684,12 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -704,12 +701,12 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -730,12 +727,12 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -750,12 +747,12 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -767,12 +764,12 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -813,12 +810,12 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -830,12 +827,12 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -847,12 +844,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -867,12 +864,12 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) @@ -918,12 +915,12 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) @@ -944,12 +941,12 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) @@ -964,12 +961,12 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) @@ -984,12 +981,12 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) @@ -1004,12 +1001,12 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) @@ -1069,12 +1066,12 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) @@ -1086,12 +1083,12 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) @@ -1106,12 +1103,12 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) @@ -1135,12 +1132,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) @@ -1161,12 +1158,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) @@ -1187,12 +1184,12 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) @@ -1225,12 +1222,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) @@ -1251,12 +1248,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) @@ -1277,12 +1274,12 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) @@ -1313,7 +1310,13 @@ func (ec *executionContext) _Event(ctx context.Context, sel ast.SelectionSet, ob } } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) interface{} { +func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() res, err := ec.ResolverMiddleware(ctx, next) if err != nil { ec.Error(ctx, err) diff --git a/example/starwars/generated.go b/example/starwars/generated.go index 5635fdb578f..e0b971931a4 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -7,6 +7,7 @@ import ( context "context" fmt "fmt" strconv "strconv" + sync "sync" time "time" graphql "github.com/99designs/gqlgen/graphql" @@ -125,6 +126,7 @@ var droidImplementors = []string{"Droid", "Character"} func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, obj *Droid) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, droidImplementors) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -137,9 +139,17 @@ func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, ob case "name": out.Values[i] = ec._Droid_name(ctx, field, obj) case "friends": - out.Values[i] = ec._Droid_friends(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Droid_friends(ctx, field, obj) + wg.Done() + }(i, field) case "friendsConnection": - out.Values[i] = ec._Droid_friendsConnection(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Droid_friendsConnection(ctx, field, obj) + wg.Done() + }(i, field) case "appearsIn": out.Values[i] = ec._Droid_appearsIn(ctx, field, obj) case "primaryFunction": @@ -148,17 +158,17 @@ func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, ob panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Droid" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Droid", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -170,12 +180,12 @@ func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.Collect } func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Droid" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Droid", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -187,38 +197,29 @@ func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.Colle } func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Droid", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Droid().Friends(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Droid().Friends(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Character) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._Character(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Character) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._Character(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { @@ -254,38 +255,29 @@ func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field } } args["after"] = arg1 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Droid", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Droid().FriendsConnection(ctx, obj, args["first"].(*int), args["after"].(*string)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Droid().FriendsConnection(ctx, obj, args["first"].(*int), args["after"].(*string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(FriendsConnection) - return ec._FriendsConnection(ctx, field.Selections, &res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(FriendsConnection) + return ec._FriendsConnection(ctx, field.Selections, &res) } func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Droid" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Droid", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.AppearsIn, nil }) @@ -306,12 +298,12 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. } func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Droid" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Droid", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.PrimaryFunction, nil }) @@ -328,6 +320,7 @@ var friendsConnectionImplementors = []string{"FriendsConnection"} func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.SelectionSet, obj *FriendsConnection) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, friendsConnectionImplementors) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -338,26 +331,34 @@ func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.Sele case "totalCount": out.Values[i] = ec._FriendsConnection_totalCount(ctx, field, obj) case "edges": - out.Values[i] = ec._FriendsConnection_edges(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._FriendsConnection_edges(ctx, field, obj) + wg.Done() + }(i, field) case "friends": - out.Values[i] = ec._FriendsConnection_friends(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._FriendsConnection_friends(ctx, field, obj) + wg.Done() + }(i, field) case "pageInfo": out.Values[i] = ec._FriendsConnection_pageInfo(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "FriendsConnection" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "FriendsConnection", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.TotalCount(), nil }) @@ -369,82 +370,64 @@ func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, f } func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "FriendsConnection", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.FriendsConnection().Edges(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.FriendsConnection().Edges(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]FriendsEdge) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._FriendsEdge(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]FriendsEdge) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._FriendsEdge(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "FriendsConnection", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.FriendsConnection().Friends(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.FriendsConnection().Friends(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Character) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._Character(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Character) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._Character(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "FriendsConnection" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "FriendsConnection", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.PageInfo(), nil }) @@ -481,12 +464,12 @@ func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "FriendsEdge" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "FriendsEdge", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Cursor, nil }) @@ -498,12 +481,12 @@ func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graph } func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "FriendsEdge" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "FriendsEdge", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Node, nil }) @@ -520,6 +503,7 @@ var humanImplementors = []string{"Human", "Character"} func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, obj *Human) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, humanImplementors) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -536,28 +520,40 @@ func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, ob case "mass": out.Values[i] = ec._Human_mass(ctx, field, obj) case "friends": - out.Values[i] = ec._Human_friends(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Human_friends(ctx, field, obj) + wg.Done() + }(i, field) case "friendsConnection": - out.Values[i] = ec._Human_friendsConnection(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Human_friendsConnection(ctx, field, obj) + wg.Done() + }(i, field) case "appearsIn": out.Values[i] = ec._Human_appearsIn(ctx, field, obj) case "starships": - out.Values[i] = ec._Human_starships(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Human_starships(ctx, field, obj) + wg.Done() + }(i, field) default: panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _Human_id(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Human" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Human", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -569,12 +565,12 @@ func (ec *executionContext) _Human_id(ctx context.Context, field graphql.Collect } func (ec *executionContext) _Human_name(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Human" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Human", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -598,12 +594,12 @@ func (ec *executionContext) _Human_height(ctx context.Context, field graphql.Col } } args["unit"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Human" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Human", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Height(args["unit"].(LengthUnit)), nil }) @@ -615,12 +611,12 @@ func (ec *executionContext) _Human_height(ctx context.Context, field graphql.Col } func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Human" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Human", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Mass, nil }) @@ -632,38 +628,29 @@ func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.Colle } func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Human", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Human().Friends(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Human().Friends(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Character) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._Character(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Character) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._Character(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { @@ -699,38 +686,29 @@ func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field } } args["after"] = arg1 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Human", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Human().FriendsConnection(ctx, obj, args["first"].(*int), args["after"].(*string)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Human().FriendsConnection(ctx, obj, args["first"].(*int), args["after"].(*string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(FriendsConnection) - return ec._FriendsConnection(ctx, field.Selections, &res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(FriendsConnection) + return ec._FriendsConnection(ctx, field.Selections, &res) } func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Human" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Human", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.AppearsIn, nil }) @@ -751,38 +729,29 @@ func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql. } func (ec *executionContext) _Human_starships(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Human", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Human().Starships(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Human().Starships(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Starship) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._Starship(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Starship) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._Starship(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } var mutationImplementors = []string{"Mutation"} @@ -835,12 +804,12 @@ func (ec *executionContext) _Mutation_createReview(ctx context.Context, field gr } } args["review"] = arg1 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Mutation" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Mutation", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.resolvers.Mutation().CreateReview(ctx, args["episode"].(Episode), args["review"].(Review)) }) @@ -882,12 +851,12 @@ func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "PageInfo" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "PageInfo", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.StartCursor, nil }) @@ -899,12 +868,12 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra } func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "PageInfo" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "PageInfo", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.EndCursor, nil }) @@ -916,12 +885,12 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph } func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "PageInfo" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "PageInfo", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.HasNextPage, nil }) @@ -942,6 +911,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -950,19 +920,47 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "__typename": out.Values[i] = graphql.MarshalString("Query") case "hero": - out.Values[i] = ec._Query_hero(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_hero(ctx, field) + wg.Done() + }(i, field) case "reviews": - out.Values[i] = ec._Query_reviews(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_reviews(ctx, field) + wg.Done() + }(i, field) case "search": - out.Values[i] = ec._Query_search(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_search(ctx, field) + wg.Done() + }(i, field) case "character": - out.Values[i] = ec._Query_character(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_character(ctx, field) + wg.Done() + }(i, field) case "droid": - out.Values[i] = ec._Query_droid(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_droid(ctx, field) + wg.Done() + }(i, field) case "human": - out.Values[i] = ec._Query_human(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_human(ctx, field) + wg.Done() + }(i, field) case "starship": - out.Values[i] = ec._Query_starship(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_starship(ctx, field) + wg.Done() + }(i, field) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -971,7 +969,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } @@ -988,29 +986,20 @@ func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.Colle } } args["episode"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Hero(ctx, args["episode"].(Episode)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Hero(ctx, args["episode"].(Episode)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(Character) - return ec._Character(ctx, field.Selections, &res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(Character) + return ec._Character(ctx, field.Selections, &res) } func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1041,38 +1030,29 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co } } args["since"] = arg1 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Reviews(ctx, args["episode"].(Episode), args["since"].(*time.Time)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Reviews(ctx, args["episode"].(Episode), args["since"].(*time.Time)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Review) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._Review(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Review) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._Review(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1088,38 +1068,29 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col } } args["text"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Search(ctx, args["text"].(string)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Search(ctx, args["text"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]SearchResult) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._SearchResult(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]SearchResult) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._SearchResult(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _Query_character(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1135,29 +1106,20 @@ func (ec *executionContext) _Query_character(ctx context.Context, field graphql. } } args["id"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Character(ctx, args["id"].(string)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Character(ctx, args["id"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(Character) - return ec._Character(ctx, field.Selections, &res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(Character) + return ec._Character(ctx, field.Selections, &res) } func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1173,32 +1135,23 @@ func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.Coll } } args["id"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Droid(ctx, args["id"].(string)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Droid(ctx, args["id"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Droid) - if res == nil { - return graphql.Null - } - return ec._Droid(ctx, field.Selections, res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Droid) + if res == nil { + return graphql.Null + } + return ec._Droid(ctx, field.Selections, res) } func (ec *executionContext) _Query_human(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1214,32 +1167,23 @@ func (ec *executionContext) _Query_human(ctx context.Context, field graphql.Coll } } args["id"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Human(ctx, args["id"].(string)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Human(ctx, args["id"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Human) - if res == nil { - return graphql.Null - } - return ec._Human(ctx, field.Selections, res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Human) + if res == nil { + return graphql.Null + } + return ec._Human(ctx, field.Selections, res) } func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1255,32 +1199,23 @@ func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.C } } args["id"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Starship(ctx, args["id"].(string)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Starship(ctx, args["id"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Starship) - if res == nil { - return graphql.Null - } - return ec._Starship(ctx, field.Selections, res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Starship) + if res == nil { + return graphql.Null + } + return ec._Starship(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1296,12 +1231,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } } args["name"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) @@ -1316,12 +1251,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) @@ -1363,12 +1298,12 @@ func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, o } func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Review" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Review", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Stars, nil }) @@ -1380,12 +1315,12 @@ func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.Col } func (ec *executionContext) _Review_commentary(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Review" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Review", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Commentary, nil }) @@ -1400,12 +1335,12 @@ func (ec *executionContext) _Review_commentary(ctx context.Context, field graphq } func (ec *executionContext) _Review_time(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Review" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Review", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Time, nil }) @@ -1422,6 +1357,7 @@ var starshipImplementors = []string{"Starship"} func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, obj *Starship) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, starshipImplementors) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -1434,24 +1370,28 @@ func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, case "name": out.Values[i] = ec._Starship_name(ctx, field, obj) case "length": - out.Values[i] = ec._Starship_length(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Starship_length(ctx, field, obj) + wg.Done() + }(i, field) case "history": out.Values[i] = ec._Starship_history(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Starship" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Starship", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -1463,12 +1403,12 @@ func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.Coll } func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Starship" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Starship", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -1492,38 +1432,29 @@ func (ec *executionContext) _Starship_length(ctx context.Context, field graphql. } } args["unit"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Starship", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Starship().Length(ctx, obj, args["unit"].(LengthUnit)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Starship().Length(ctx, obj, args["unit"].(LengthUnit)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(float64) - return graphql.MarshalFloat(res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + return graphql.MarshalFloat(res) } func (ec *executionContext) _Starship_history(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Starship" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Starship", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.History, nil }) @@ -1582,12 +1513,12 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -1599,12 +1530,12 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -1616,12 +1547,12 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) @@ -1642,12 +1573,12 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -1697,12 +1628,12 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -1714,12 +1645,12 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -1731,12 +1662,12 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -1748,12 +1679,12 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -1798,12 +1729,12 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -1815,12 +1746,12 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -1832,12 +1763,12 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -1858,12 +1789,12 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -1878,12 +1809,12 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -1895,12 +1826,12 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -1941,12 +1872,12 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -1958,12 +1889,12 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -1975,12 +1906,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -1995,12 +1926,12 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) @@ -2046,12 +1977,12 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) @@ -2072,12 +2003,12 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) @@ -2092,12 +2023,12 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) @@ -2112,12 +2043,12 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) @@ -2132,12 +2063,12 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) @@ -2197,12 +2128,12 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) @@ -2214,12 +2145,12 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) @@ -2234,12 +2165,12 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) @@ -2263,12 +2194,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) @@ -2289,12 +2220,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) @@ -2315,12 +2246,12 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) @@ -2353,12 +2284,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) @@ -2379,12 +2310,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) @@ -2405,12 +2336,12 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) @@ -2497,7 +2428,13 @@ func UnmarshalReviewInput(v interface{}) (Review, error) { return it, nil } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) interface{} { +func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() res, err := ec.ResolverMiddleware(ctx, next) if err != nil { ec.Error(ctx, err) diff --git a/example/todo/generated.go b/example/todo/generated.go index 704581b9b7b..69f28e9a529 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -6,6 +6,7 @@ import ( "bytes" context "context" strconv "strconv" + sync "sync" graphql "github.com/99designs/gqlgen/graphql" introspection "github.com/99designs/gqlgen/graphql/introspection" @@ -137,12 +138,12 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr } } args["todo"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "MyMutation" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "MyMutation", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.resolvers.MyMutation().CreateTodo(ctx, args["todo"].(TodoInput)) }) @@ -176,12 +177,12 @@ func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field gr } } args["changes"] = arg1 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "MyMutation" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "MyMutation", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.resolvers.MyMutation().UpdateTodo(ctx, args["id"].(int), args["changes"].(map[string]interface{})) }) @@ -205,6 +206,7 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) Object: "MyQuery", }) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -213,13 +215,29 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) case "__typename": out.Values[i] = graphql.MarshalString("MyQuery") case "todo": - out.Values[i] = ec._MyQuery_todo(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._MyQuery_todo(ctx, field) + wg.Done() + }(i, field) case "authenticatedTodo": - out.Values[i] = ec._MyQuery_authenticatedTodo(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._MyQuery_authenticatedTodo(ctx, field) + wg.Done() + }(i, field) case "lastTodo": - out.Values[i] = ec._MyQuery_lastTodo(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._MyQuery_lastTodo(ctx, field) + wg.Done() + }(i, field) case "todos": - out.Values[i] = ec._MyQuery_todos(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._MyQuery_todos(ctx, field) + wg.Done() + }(i, field) case "__type": out.Values[i] = ec._MyQuery___type(ctx, field) case "__schema": @@ -228,7 +246,7 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } @@ -245,32 +263,23 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col } } args["id"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + 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().Todo(ctx, args["id"].(int)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.MyQuery().Todo(ctx, args["id"].(int)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Todo) - if res == nil { - return graphql.Null - } - return ec._Todo(ctx, field.Selections, res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Todo) + if res == nil { + return graphql.Null + } + return ec._Todo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_authenticatedTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -286,96 +295,69 @@ func (ec *executionContext) _MyQuery_authenticatedTodo(ctx context.Context, fiel } } args["id"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + 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)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - 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) - if res == nil { - return graphql.Null - } - return ec._Todo(ctx, field.Selections, res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Todo) + if res == nil { + return graphql.Null + } + return ec._Todo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "MyQuery", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.MyQuery().LastTodo(ctx) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.MyQuery().LastTodo(ctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Todo) - if res == nil { - return graphql.Null - } - return ec._Todo(ctx, field.Selections, res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Todo) + if res == nil { + return graphql.Null + } + return ec._Todo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "MyQuery", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.MyQuery().Todos(ctx) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.MyQuery().Todos(ctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Todo) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return ec._Todo(ctx, field.Selections, &res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Todo) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return ec._Todo(ctx, field.Selections, &res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -391,12 +373,12 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C } } args["name"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "MyQuery" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + 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.introspectType(args["name"].(string)), nil }) @@ -411,12 +393,12 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C } func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "MyQuery" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "MyQuery", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) @@ -458,12 +440,12 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj } func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Todo" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.ID, nil }) @@ -475,12 +457,12 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Todo" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Text, nil }) @@ -492,12 +474,12 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec } func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Todo" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Done, nil }) @@ -538,12 +520,12 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -555,12 +537,12 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -572,12 +554,12 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) @@ -598,12 +580,12 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -653,12 +635,12 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -670,12 +652,12 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -687,12 +669,12 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -704,12 +686,12 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -754,12 +736,12 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -771,12 +753,12 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -788,12 +770,12 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -814,12 +796,12 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -834,12 +816,12 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -851,12 +833,12 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -897,12 +879,12 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -914,12 +896,12 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -931,12 +913,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -951,12 +933,12 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) @@ -1002,12 +984,12 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) @@ -1028,12 +1010,12 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) @@ -1048,12 +1030,12 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) @@ -1068,12 +1050,12 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) @@ -1088,12 +1070,12 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) @@ -1153,12 +1135,12 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) @@ -1170,12 +1152,12 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) @@ -1190,12 +1172,12 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) @@ -1219,12 +1201,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) @@ -1245,12 +1227,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) @@ -1271,12 +1253,12 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) @@ -1309,12 +1291,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) @@ -1335,12 +1317,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) @@ -1361,12 +1343,12 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) @@ -1409,7 +1391,13 @@ func UnmarshalTodoInput(v interface{}) (TodoInput, error) { return it, nil } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) interface{} { +func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() rctx := graphql.GetResolverContext(ctx) for _, d := range rctx.Field.Definition.Directives { switch d.Name { diff --git a/example/todo/todo.go b/example/todo/todo.go index 872489a4de2..ceeffdf75b6 100644 --- a/example/todo/todo.go +++ b/example/todo/todo.go @@ -7,7 +7,7 @@ import ( "errors" "time" - graphql "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql" "github.com/mitchellh/mapstructure" ) diff --git a/graphql/context.go b/graphql/context.go index 8fe5155e08b..63c01c86797 100644 --- a/graphql/context.go +++ b/graphql/context.go @@ -75,46 +75,54 @@ func WithRequestContext(ctx context.Context, rc *RequestContext) context.Context } type ResolverContext struct { + Parent *ResolverContext // The name of the type this field belongs to Object string // These are the args after processing, they can be mutated in middleware to change what the resolver will get. Args map[string]interface{} // The raw field Field CollectedField - // The path of fields to get to this resolver - Path []interface{} + + // indicies tracks the array indicies only. all field aliases come from the context stack + indicies []int } -func (r *ResolverContext) PushField(alias string) { - r.Path = append(r.Path, alias) +func (r *ResolverContext) Path() []interface{} { + var path []interface{} + for it := r; it != nil; it = it.Parent { + for i := len(it.indicies) - 1; i >= 0; i-- { + path = append(path, it.indicies[i]) + } + + if it.Field.Field != nil { + path = append(path, it.Field.Alias) + } + } + + // because we are walking up the chain, all the elements are backwards, do an inplace flip. + for i := len(path)/2 - 1; i >= 0; i-- { + opp := len(path) - 1 - i + path[i], path[opp] = path[opp], path[i] + } + + return path } func (r *ResolverContext) PushIndex(index int) { - r.Path = append(r.Path, index) + r.indicies = append(r.indicies, index) } func (r *ResolverContext) Pop() { - r.Path = r.Path[0 : len(r.Path)-1] + r.indicies = r.indicies[0 : len(r.indicies)-1] } func GetResolverContext(ctx context.Context) *ResolverContext { - val := ctx.Value(resolver) - if val == nil { - return nil - } - - return val.(*ResolverContext) + val, _ := ctx.Value(resolver).(*ResolverContext) + return val } func WithResolverContext(ctx context.Context, rc *ResolverContext) context.Context { - parent := GetResolverContext(ctx) - rc.Path = nil - if parent != nil { - rc.Path = append(rc.Path, parent.Path...) - } - if rc.Field.Field != nil && rc.Field.Alias != "" { - rc.PushField(rc.Field.Alias) - } + rc.Parent = GetResolverContext(ctx) return context.WithValue(ctx, resolver, rc) } diff --git a/graphql/defer.go b/graphql/defer.go deleted file mode 100644 index 79346a84681..00000000000 --- a/graphql/defer.go +++ /dev/null @@ -1,30 +0,0 @@ -package graphql - -import ( - "io" - "sync" -) - -// Defer will begin executing the given function and immediately return a result that will block until the function completes -func Defer(f func() Marshaler) Marshaler { - var deferred deferred - deferred.mu.Lock() - - go func() { - deferred.result = f() - deferred.mu.Unlock() - }() - - return &deferred -} - -type deferred struct { - result Marshaler - mu sync.Mutex -} - -func (d *deferred) MarshalGQL(w io.Writer) { - d.mu.Lock() - d.result.MarshalGQL(w) - d.mu.Unlock() -} diff --git a/graphql/defer_test.go b/graphql/defer_test.go deleted file mode 100644 index 8f3eeae27e2..00000000000 --- a/graphql/defer_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package graphql - -import ( - "bytes" - "testing" - "time" - - "github.com/stretchr/testify/require" -) - -func TestDeferred(t *testing.T) { - result := Defer(func() Marshaler { - time.Sleep(10 * time.Millisecond) - return Null - }) - - var b bytes.Buffer - result.MarshalGQL(&b) - require.Equal(t, "null", b.String()) -} diff --git a/graphql/error.go b/graphql/error.go index 58f409c33f1..7f161a4306b 100644 --- a/graphql/error.go +++ b/graphql/error.go @@ -14,7 +14,7 @@ type ExtendedError interface { func DefaultErrorPresenter(ctx context.Context, err error) *gqlerror.Error { if gqlerr, ok := err.(*gqlerror.Error); ok { - gqlerr.Path = GetResolverContext(ctx).Path + gqlerr.Path = GetResolverContext(ctx).Path() return gqlerr } @@ -25,7 +25,7 @@ func DefaultErrorPresenter(ctx context.Context, err error) *gqlerror.Error { return &gqlerror.Error{ Message: err.Error(), - Path: GetResolverContext(ctx).Path, + Path: GetResolverContext(ctx).Path(), Extensions: extensions, } } diff --git a/integration/generated.go b/integration/generated.go index 4187ad8c3f9..ecd15597e03 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -7,6 +7,7 @@ import ( context "context" remote_api "remote_api" strconv "strconv" + sync "sync" graphql "github.com/99designs/gqlgen/graphql" introspection "github.com/99designs/gqlgen/graphql/introspection" @@ -96,6 +97,7 @@ var elementImplementors = []string{"Element"} func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, obj *models.Element) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, elementImplementors) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -104,104 +106,89 @@ func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, case "__typename": out.Values[i] = graphql.MarshalString("Element") case "child": - out.Values[i] = ec._Element_child(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Element_child(ctx, field, obj) + wg.Done() + }(i, field) case "error": - out.Values[i] = ec._Element_error(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Element_error(ctx, field, obj) + wg.Done() + }(i, field) case "mismatched": - out.Values[i] = ec._Element_mismatched(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Element_mismatched(ctx, field, obj) + wg.Done() + }(i, field) default: panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _Element_child(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Element", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Element().Child(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Element().Child(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(models.Element) - return ec._Element(ctx, field.Selections, &res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(models.Element) + return ec._Element(ctx, field.Selections, &res) } func (ec *executionContext) _Element_error(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Element", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Element().Error(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Element().Error(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(bool) - return graphql.MarshalBoolean(res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(bool) + return graphql.MarshalBoolean(res) } func (ec *executionContext) _Element_mismatched(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Element", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Element().Mismatched(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Element().Mismatched(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]bool) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return graphql.MarshalBoolean(res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]bool) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return graphql.MarshalBoolean(res[idx1]) + }()) + } + return arr1 } var queryImplementors = []string{"Query"} @@ -214,6 +201,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -222,15 +210,35 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "__typename": out.Values[i] = graphql.MarshalString("Query") case "path": - out.Values[i] = ec._Query_path(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_path(ctx, field) + wg.Done() + }(i, field) case "date": - out.Values[i] = ec._Query_date(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_date(ctx, field) + wg.Done() + }(i, field) case "viewer": - out.Values[i] = ec._Query_viewer(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_viewer(ctx, field) + wg.Done() + }(i, field) case "jsonEncoding": - out.Values[i] = ec._Query_jsonEncoding(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_jsonEncoding(ctx, field) + wg.Done() + }(i, field) case "error": - out.Values[i] = ec._Query_error(ctx, field) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_error(ctx, field) + wg.Done() + }(i, field) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -239,46 +247,37 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _Query_path(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Path(ctx) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*models.Element) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + if res[idx1] == nil { + return graphql.Null } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Path(ctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*models.Element) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - if res[idx1] == nil { - return graphql.Null - } - return ec._Element(ctx, field.Selections, res[idx1]) - }()) - } - return arr1 - }) + return ec._Element(ctx, field.Selections, res[idx1]) + }()) + } + return arr1 } func (ec *executionContext) _Query_date(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -294,84 +293,57 @@ func (ec *executionContext) _Query_date(ctx context.Context, field graphql.Colle } } args["filter"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Date(ctx, args["filter"].(models.DateFilter)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Date(ctx, args["filter"].(models.DateFilter)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(bool) - return graphql.MarshalBoolean(res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(bool) + return graphql.MarshalBoolean(res) } func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Viewer(ctx) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Viewer(ctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*models.Viewer) - if res == nil { - return graphql.Null - } - return ec._Viewer(ctx, field.Selections, res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*models.Viewer) + if res == nil { + return graphql.Null + } + return ec._Viewer(ctx, field.Selections, res) } func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().JSONEncoding(ctx) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().JSONEncoding(ctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - return graphql.MarshalString(res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + return graphql.MarshalString(res) } func (ec *executionContext) _Query_error(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -387,29 +359,20 @@ func (ec *executionContext) _Query_error(ctx context.Context, field graphql.Coll } } args["type"] = arg0 - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "Query", Args: args, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Query().Error(ctx, args["type"].(models.ErrorType)) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.Query().Error(ctx, args["type"].(models.ErrorType)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(bool) - return graphql.MarshalBoolean(res) - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(bool) + return graphql.MarshalBoolean(res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -425,12 +388,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } } args["name"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectType(args["name"].(string)), nil }) @@ -445,12 +408,12 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Query" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return ec.introspectSchema(), nil }) @@ -470,6 +433,7 @@ var userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *remote_api.User) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, userImplementors) + var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { out.Keys[i] = field.Alias @@ -480,22 +444,26 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj case "name": out.Values[i] = ec._User_name(ctx, field, obj) case "likes": - out.Values[i] = ec._User_likes(ctx, field, obj) + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._User_likes(ctx, field, obj) + wg.Done() + }(i, field) default: panic("unknown field " + strconv.Quote(field.Name)) } } - + wg.Wait() return out } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "User" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "User", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -507,38 +475,29 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec } func (ec *executionContext) _User_likes(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + rctx := &graphql.ResolverContext{ Object: "User", Args: nil, Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.User().Likes(ctx, obj) }) - return graphql.Defer(func() (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - userErr := ec.Recover(ctx, r) - ec.Error(ctx, userErr) - ret = graphql.Null - } - }() - - resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { - return ec.resolvers.User().Likes(ctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]string) - arr1 := graphql.Array{} - for idx1 := range res { - arr1 = append(arr1, func() graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.PushIndex(idx1) - defer rctx.Pop() - return graphql.MarshalString(res[idx1]) - }()) - } - return arr1 - }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]string) + arr1 := graphql.Array{} + for idx1 := range res { + arr1 = append(arr1, func() graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.PushIndex(idx1) + defer rctx.Pop() + return graphql.MarshalString(res[idx1]) + }()) + } + return arr1 } var viewerImplementors = []string{"Viewer"} @@ -565,12 +524,12 @@ func (ec *executionContext) _Viewer(ctx context.Context, sel ast.SelectionSet, o } func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.CollectedField, obj *models.Viewer) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Viewer" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "Viewer", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.User, nil }) @@ -614,12 +573,12 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -631,12 +590,12 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -648,12 +607,12 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Locations, nil }) @@ -674,12 +633,12 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Directive" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -729,12 +688,12 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -746,12 +705,12 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -763,12 +722,12 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -780,12 +739,12 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__EnumValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -830,12 +789,12 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -847,12 +806,12 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -864,12 +823,12 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Args, nil }) @@ -890,12 +849,12 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -910,12 +869,12 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.IsDeprecated, nil }) @@ -927,12 +886,12 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Field" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DeprecationReason, nil }) @@ -973,12 +932,12 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name, nil }) @@ -990,12 +949,12 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description, nil }) @@ -1007,12 +966,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Type, nil }) @@ -1027,12 +986,12 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__InputValue" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.DefaultValue, nil }) @@ -1078,12 +1037,12 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Types(), nil }) @@ -1104,12 +1063,12 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.QueryType(), nil }) @@ -1124,12 +1083,12 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.MutationType(), nil }) @@ -1144,12 +1103,12 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.SubscriptionType(), nil }) @@ -1164,12 +1123,12 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Schema" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Directives(), nil }) @@ -1229,12 +1188,12 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Kind(), nil }) @@ -1246,12 +1205,12 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Name(), nil }) @@ -1266,12 +1225,12 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Description(), nil }) @@ -1295,12 +1254,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Fields(args["includeDeprecated"].(bool)), nil }) @@ -1321,12 +1280,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.Interfaces(), nil }) @@ -1347,12 +1306,12 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.PossibleTypes(), nil }) @@ -1385,12 +1344,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } } args["includeDeprecated"] = arg0 - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = args - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) @@ -1411,12 +1370,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.InputFields(), nil }) @@ -1437,12 +1396,12 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "__Type" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, func(ctx context.Context) (interface{}, error) { return obj.OfType(), nil }) @@ -1503,7 +1462,13 @@ func UnmarshalDateFilter(v interface{}) (models.DateFilter, error) { return it, nil } -func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) interface{} { +func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() res, err := ec.ResolverMiddleware(ctx, next) if err != nil { ec.Error(ctx, err) diff --git a/integration/server/server.go b/integration/server/server.go index a9c6685deb0..f17ed2ada91 100644 --- a/integration/server/server.go +++ b/integration/server/server.go @@ -28,7 +28,7 @@ func main() { if e, ok := errors.Cause(e).(*integration.CustomError); ok { return &gqlerror.Error{ Message: e.UserMessage, - Path: graphql.GetResolverContext(ctx).Path, + Path: graphql.GetResolverContext(ctx).Path(), } } return graphql.DefaultErrorPresenter(ctx, e)